Skip to content

Commit

Permalink
plenty of classes in the tank - use some of JRuby's instead of a dummy
Browse files Browse the repository at this point in the history
minor improvement of class.count -1 for #4266's fix
  • Loading branch information
kares committed Dec 17, 2016
1 parent 2398903 commit f17102c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
11 changes: 0 additions & 11 deletions core/src/main/java/org/jruby/javasupport/DummyForJavaUtil.java

This file was deleted.

5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/javasupport/Java.java
Expand Up @@ -1647,4 +1647,9 @@ static boolean isDefaultMethod(final Method method) {
return false;
}

/**
* @see JavaUtil#CAN_SET_ACCESSIBLE
*/
@SuppressWarnings("unused") private static final byte _ = 72;

}
11 changes: 6 additions & 5 deletions core/src/main/java/org/jruby/javasupport/JavaUtil.java
Expand Up @@ -98,12 +98,13 @@ public class JavaUtil {

if (RubyInstanceConfig.CAN_SET_ACCESSIBLE) {
try {
// We want to check if we can access a commonly-existing private field through reflection. If so,
// we're probably able to access some other fields too later on.
Field f = DummyForJavaUtil.class.getDeclaredField("PRIVATE");
// We want to check if we can access a commonly-existing private field through reflection.
// If so, we're probably able to access some other fields too later on.
Field f = Java.class.getDeclaredField("_");
f.setAccessible(true);
canSetAccessible = f.get(null).equals(DummyForJavaUtil.PUBLIC);
} catch (Exception t) {
canSetAccessible = f.getByte(null) == 72;
}
catch (Exception t) {
// added this so if things are weird in the future we can debug without
// spinning a new binary
if (Options.JI_LOGCANSETACCESSIBLE.load()) {
Expand Down

1 comment on commit f17102c

@headius
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.