Skip to content

Commit

Permalink
Do not consider methods we will not be able to call.
Browse files Browse the repository at this point in the history
This caused java.util.Properties.new.clone to fail because we try
to use the most general implementation of a given method in our
dispatch logic (which would be Object#clone) but did not omit
methods that can't be made accessible (Object#clone is protected
and not setAccessible on JDK9 without a warning). We would proceed
to try to call those inaccessible methods since they were the
most general impl, causing an exception.
  • Loading branch information
headius committed Apr 19, 2018
1 parent 07e2088 commit 7d7081c
Showing 1 changed file with 4 additions and 0 deletions.
@@ -1,5 +1,6 @@
package org.jruby.javasupport.binding;

import com.headius.modulator.Modulator;
import org.jruby.Ruby;
import org.jruby.RubyClass;
import org.jruby.RubyModule;
Expand Down Expand Up @@ -539,6 +540,9 @@ private static int addNewMethods(
// Skip private methods, since they may mess with dispatch
if ( Modifier.isPrivate(mod) ) continue;

// Skip protected methods if we can't set accessible
if ( !Modifier.isPublic(mod) && !Modulator.trySetAccessible(method)) continue;

// ignore bridge methods because we'd rather directly call methods that this method
// is bridging (and such methods are by definition always available.)
if ( ( mod & ACC_BRIDGE ) != 0 ) continue;
Expand Down

0 comments on commit 7d7081c

Please sign in to comment.