-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Static methods do not allow code removal while static fields do #2594
Comments
This commit removes load time weaving, CGLIB and Objenesis support from native images. GraalDetector has been removed for now because of oracle/graal#2594. It should be reintroduced when this bug will be fixed with NativeImageDetector class name. Closes gh-25179
This commit removes load time weaving, CGLIB and Objenesis support from native images. GraalDetector has been removed for now because of oracle/graal#2594. It should be reintroduced when this bug will be fixed with NativeImageDetector class name. Closes spring-projectsgh-25179
The static analysis currently is not context sensitive and also does not do any inlining. Therefore, even tiny helper methods like We have a research project that tries to address this limitation. However, the solution is not as trivial as it sounds ("just always inline this method"), because we really need to guarantee that inlining happens in all places, which requires a bit of implementation. |
@eginez I am not sure to understand why this issue is closed, despite being non trivial to fix isn't it a real open issue? See for example https://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/tomcat/util/compat/JreCompat.html#isGraalAvailable-- that shows that Tomcat team and likely many others have the same expectation than us. Is there a root issue to track progresses on you research project? |
@sdeleuze I think it makes sense to keep this open to track future development on this issue, for now, however nothing is planned |
Testing if Apache Tomcat is affected
@vjovanov @christianwimmer As discussed recently, could we move this issue to 20.3 since it seems the potential fix for #2500 will fix this one as well? |
We have a research project that looks at method inlining before static analysis #2860. In #2860 (comment) you'll find examples for fixing #2500. |
This should be addressed by the following commit: 17f1de4 Feel free to try this out by using |
I confirm |
Describe the issue
Static
boolean
fields of classes initialized at build time are effective for code removal when used inif
statements while static methods returning the very same field are not.Steps to reproduce the issue
Consider this simple class (initialized at build time) used to detect if the code is running as a native image or not:
If the static field is used in an
if
statement:As expected the message is not printed on the console and
com.sample.Foo
is not referenced in the used classes visible in the report generated via-H:+PrintAnalysisCallTree
.But if we do the same with the static method:
As expected the message is not printed on the console.
But
com.sample.Foo
is referenced in the used classes visible in the report generated via `-H:+PrintAnalysisCallTree. Such class should be not be referenced here nor part of the static image, the static method and static field variants should be equivalent for such trivial level of indirection.Check https://github.com/sdeleuze/graalvm-native-issues/tree/master/static-method-code-removal-regression and run
./build.sh
to reproduce the issue.Describe GraalVM and your environment:
The text was updated successfully, but these errors were encountered: