Add Java 11 Nestmate support to java.lang.Class model#580
Conversation
|
Hi @cyrille-artho, following your advice to focus on functionality rather than test optimization, I've submitted a PR adding Java 11 Nestmate support ( I included a new unit test to verify the behavior for both top-level and inner classes. Ready for your review! |
cyrille-artho
left a comment
There was a problem hiding this comment.
Thank you for this addition. The implementation looks correct, and a few more tests against unusual cases can ascertain that.
Please remove the extensive formatting changes at the beginning, as this increases the size of the patch and may make it hard to merge to other branches later.
| * in compliance with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0. | ||
| * * http://www.apache.org/licenses/LICENSE-2.0. |
There was a problem hiding this comment.
Please try not to reformat existing code/comments, as this can make it harder to merge your patch into other branches later.
| public class Inner {} | ||
|
|
||
| @Test | ||
| public void testNestHost() { |
There was a problem hiding this comment.
Looks good. Please also add a test for some other cases: "If this Class object represents a primitive type, an array type, or void, then this method returns this".
4b350ba to
089d26b
Compare
|
Thanks for the review, @cyrille-artho! I have reverted the formatting changes to the license header to keep the diff clean. I also added the requested test cases for primitives, arrays, and void in NestmateTest.java. Ready for another look! |
Summary
Implemented missing Java 11 Nestmate access control methods in the
java.lang.Classmodel. This allows JPF to execute code that relies ongetNestHost()andisNestmateOf(), which are increasingly common in modern Java libraries.Changes
src/classes/modules/java.base/java/lang/Class.javagetNestHost(): TraversinggetEnclosingClass()to find the nest host (top-level class).isNestmateOf(Class): Compares nest hosts of two classes.src/tests/gov/nasa/jpf/test/java/lang/NestmateTest.javaTesting
NestmateTest.javapassesRelation to Issues
Partial fix for general "Missing Methods in Class" issues (like #235), specifically targeting Java 11 support.