-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move/Refactor ReflectionTest -> StackWalkerTest #83
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sun.reflect.Reflection#getCallerClass is an internal API and is marked for removal. This uses StackWalker to walk the stack and obtain the caller class with StackWalker.StackFrame.getDeclaringClass instead. The class is also being renamed from 'gov.nasa.jpf.test.vm.reflection.ReflectionTest' to 'gov.nasa.jpf.test.java.lang.StackWalkerTest' for consistency. Fixes: javapathfinder#81
I remote debug to make sure that the assertions in this test pass, as the test would still fail when running |
gayanW
added a commit
to gayanW/jpf-core
that referenced
this pull request
Jul 19, 2018
JVMClassInfo.Initializer#setBootstrapMethod assumes to have a bootstrap method with a structure similar to the following (with 3 bootstrap method arguments) BootstrapMethods: 0: javapathfinder#83 REF_invokeStatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; Method arguments: javapathfinder#84 (Ljava/lang/Object;)Ljava/lang/Object; javapathfinder#85 REF_invokeInterface java/lang/annotation/Annotation.annotationType:()Ljava/lang/Class; javapathfinder#86 (Ljava/lang/annotation/Annotation;)Ljava/lang/Class; But if JPF encounters an bootstrap method with arbitary numer of arguments such as the StringConcatFactory.makeConcatWithConstants which have only one bootstrap method argument it results in an ArrayIndexOutOfBoundsException exception: [junit] java.lang.ArrayIndexOutOfBoundsException: 1 [junit] at gov.nasa.jpf.jvm.JVMClassInfo$Initializer.setBootstrapMethod(JVMClassInfo.java:93) [junit] at gov.nasa.jpf.jvm.ClassFile.setBootstrapMethod(ClassFile.java:659) [junit] at gov.nasa.jpf.jvm.ClassFile.parseBootstrapMethodAttr(ClassFile.java:1422) [junit] at gov.nasa.jpf.jvm.JVMClassInfo$Initializer.setClassAttribute(JVMClassInfo.java:80) [junit] at gov.nasa.jpf.jvm.ClassFile.setClassAttribute(ClassFile.java:636) [junit] at gov.nasa.jpf.jvm.ClassFile.parseClassAttributes(ClassFile.java:1306) [junit] at gov.nasa.jpf.jvm.ClassFile.parse(ClassFile.java:875) [junit] at gov.nasa.jpf.jvm.JVMClassInfo$Initializer.<init>(JVMClassInfo.java:48) This prevents the above exception from being thrown, by adding a new constructor BootstrapMethodInfo#BootstrapMethodInfo(enclosingClass, cpArgs) for handling bootstrap methods with arbitrary number of bootstrap method arguments, without evaluating cpArgs in JVMClassInfo.Initializer#setBootstrapMethod.
gayanW
added a commit
to gayanW/jpf-core
that referenced
this pull request
Jul 19, 2018
JVMClassInfo.Initializer#setBootstrapMethod assumes to have a bootstrap method with a structure similar to the following (with 3 bootstrap method arguments) BootstrapMethods: 0: javapathfinder#83 REF_invokeStatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; Method arguments: javapathfinder#84 (Ljava/lang/Object;)Ljava/lang/Object; javapathfinder#85 REF_invokeInterface java/lang/annotation/Annotation.annotationType:()Ljava/lang/Class; javapathfinder#86 (Ljava/lang/annotation/Annotation;)Ljava/lang/Class; In case JPF encounters an bootstrap method with arbitrary number of arguments such as the StringConcatFactory.makeConcatWithConstants which have only one bootstrap method argument JVMClassInfo.Initializer#setBootstrapMethod throws an ArrayIndexOutOfBoundsException exception: [junit] java.lang.ArrayIndexOutOfBoundsException: 1 [junit] at gov.nasa.jpf.jvm.JVMClassInfo$Initializer.setBootstrapMethod(JVMClassInfo.java:93) [junit] at gov.nasa.jpf.jvm.ClassFile.setBootstrapMethod(ClassFile.java:659) [junit] at gov.nasa.jpf.jvm.ClassFile.parseBootstrapMethodAttr(ClassFile.java:1422) [junit] at gov.nasa.jpf.jvm.JVMClassInfo$Initializer.setClassAttribute(JVMClassInfo.java:80) [junit] at gov.nasa.jpf.jvm.ClassFile.setClassAttribute(ClassFile.java:636) [junit] at gov.nasa.jpf.jvm.ClassFile.parseClassAttributes(ClassFile.java:1306) [junit] at gov.nasa.jpf.jvm.ClassFile.parse(ClassFile.java:875) [junit] at gov.nasa.jpf.jvm.JVMClassInfo$Initializer.<init>(JVMClassInfo.java:48) This prevents the above exception from being thrown, by adding a new constructor BootstrapMethodInfo#BootstrapMethodInfo(enclosingClass, cpArgs) for handling bootstrap methods with arbitrary number of bootstrap method arguments, without evaluating cpArgs within JVMClassInfo.Initializer#setBootstrapMethod.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
sun.reflect.Reflection#getCallerClass
is an internal API and is markedfor removal. This uses StackWalker to walk the stack and obtain the
caller class with
StackWalker.StackFrame.getDeclaringClass
instead.The class is also being renamed from
'gov.nasa.jpf.test.vm.reflection.ReflectionTest' to
'gov.nasa.jpf.test.java.lang.StackWalkerTest' for consistency.
Fixes: #81