Skip to content

Commit

Permalink
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -36,19 +36,13 @@ public static MethodHandle getPrivateSetter(final Class<?> klass, final String f
}

private static Field getPrivateField(final Class<?> klass, final String fieldName) {
return AccessController.doPrivileged(new PrivilegedAction<Field>() {
@Override
public Field run() {
final Field field;
try {
field = klass.getDeclaredField(fieldName);
field.setAccessible(true);
return field;
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
}
});
try {
final Field field = klass.getDeclaredField(fieldName);
field.setAccessible(true);
return field;
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
}

}

3 comments on commit e0f049e

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this not trigger a FindBugs issue now? Did you annotate it somewhere?

@eregon
Copy link
Member Author

@eregon eregon commented on e0f049e Oct 8, 2015

Choose a reason for hiding this comment

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

I guess the FindBugs issue was caused by the reflective access more than setAccessible().
Or maybe it's just spurious or manage to prove the callers are fine. In any case the build seems fine.

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

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

Strange. Here's the link to the error:

https://travis-ci.org/jruby/jruby/jobs/83986914

The message is:

"L V DP: Invocation of reflect.Field.setAccessible(boolean), which should be invoked from within a doPrivileged block, in org.jruby.truffle.nodes.ext.ZlibNodes$Adler32Node.() At ZlibNodes.java:[line 163]"

Please sign in to comment.