Skip to content

[native-image] NPE in ChainedSubstitutionProcessor.lookup #968

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

Closed
johanvos opened this issue Feb 8, 2019 · 7 comments · Fixed by #1001
Closed

[native-image] NPE in ChainedSubstitutionProcessor.lookup #968

johanvos opened this issue Feb 8, 2019 · 7 comments · Fixed by #1001
Assignees

Comments

@johanvos
Copy link
Contributor

johanvos commented Feb 8, 2019

In a complex application that works fine with Java 8 on SVM, I have an issue when using Java 11.
The final error is a NullPointerException in SubstitutionProcessor$ChainedSubstitutionProcessor.lookup since the first lookup returns null in
`second.lookup(first.lookup(method))

FYI, first is an AnnotationSupport instance and declaringClass.getSubstitutionMethod(method) returns null for
declaringClass = AnnotationType<jdk.jfr.Relational$$ProxyImpl -> HotSpotType<Lcom/sun/proxy/$Proxy37;, resolved>>
and
method = HotSpotMethod<$Proxy37.<init>(InvocationHandler)>

@cstancu
Copy link
Member

cstancu commented Feb 8, 2019

@johanvos Java 11 support is currently under development. See also #561.

@johanvos
Copy link
Contributor Author

Digging a bit deeper in this, the failure occurs when trying to get the <init> method of a declaringClass that is an annotation (isAnnotation(declaringClass) returns true).
However, <init> is not in the list of methods for the corresponding Subtitution. Only equals, toString, hashCode and annotationType are added as subsitutionMethods.

The declaringClass itself is AnnotationType<jdk.internal.vm.annotation.ReservedStackAccess$$ProxyImpl -> HotSpotType<Lcom/sun/proxy/jdk/proxy1/$Proxy118;, resolved>> (hence @ReservedStackAccess)

@johanvos
Copy link
Contributor Author

In PR #981 I added the constructors to the list of substitutions, and the error is gone now. I'm not sure though if the constructors were removed deliberately (and only methods were used to create substitutions)?

@christianwimmer
Copy link

I don't see how the substitutions for the constructors could be necessary, because the annotation objects are created during image generation and not at run time. Your PR substitutes the constructor with an accessor method that returns a field value - that is clearly a wrong functionality, i.e., if the constructor would ever be called horrible things would happen.

I think we first need an investigation why the constructor is requested at all. Maybe we can fix the problem at that level. If we decide that a constructor is necessary, we can substitute it with a new AnnotationConstructor implementation, which just throws an exception in the generated graph. That way at least we have a clear and correct error message at run time instead of a major corruption of the heap.

@johanvos
Copy link
Contributor Author

The problem occurs with Proxy classes that are annotations and that have an
The should indeed not be implemented with an AnnotationAccessorMethod.

@vjovanov
Copy link
Member

The explanation about the issue can be found here.

johanvos added a commit to johanvos/graal that referenced this issue Feb 23, 2019
@johanvos
Copy link
Contributor Author

The proper fix for this is in #1001

dougxc pushed a commit that referenced this issue Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants