Skip to content
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

Cryptic parsing error messages with --link-at-build-time and incomplete classpath #6253

Open
zakkak opened this issue Mar 21, 2023 · 7 comments

Comments

@zakkak
Copy link
Collaborator

zakkak commented Mar 21, 2023

Describe the issue
Parsing errors may be cryptic when using --link-at-build-time and incomplete classpath.
For instance if a Class A cannot be initialized due to a NoClassDefFoundError caused by a missing dependency, the user will be presented with an UnresolvedElementException stating that some method of Class A is unresolved, but it won't provide any additional info on the cause.

Steps to reproduce the issue

cd /tmp
git clone --branch 2023-03-21-graal-4661-parsing-error https://github.com/zakkak/issue-reproducers reproducer
cd reproducer
mvn package
export JAVA_HOME=/path/to/graalvm
# Attempt to generate native-image
$JAVA_HOME/bin/native-image \
  --no-fallback \
  -H:+ReportExceptionStackTraces \
  --link-at-build-time \
  --initialize-at-build-time=. \
  -jar target/reproducer-1.0-SNAPSHOT.jar

Describe GraalVM and your environment:

  • GraalVM version (latest snapshot builds can be found here), or commit id if built from source: e9893c0
  • JDK major version: 20
  • OS: Fedora 37
  • Architecture: AMD64

More details

The reproducer will result in build errors like the following:

Error: Unsupported features in 2 methods
Detailed message:
Error: Discovered unresolved method during parsing: net.sf.oval.expression.ExpressionLanguageJavaScriptImpl.<init>(). This error is reported at image build time because class net.sf.oval.expression.ExpressionLanguageRegistry is registered for linking at image build time by command line.
Error encountered while parsing net.sf.oval.expression.ExpressionLanguageRegistry.getExpressionLanguage(ExpressionLanguageRegistry.java:78) 
Parsing context:
   at net.sf.oval.AbstractCheck.isActive(AbstractCheck.java:151)
   at net.sf.oval.Validator.checkConstraint(Validator.java:763)
   at net.sf.oval.Validator._validateStaticInvariants(Validator.java:670)
   at net.sf.oval.Validator.validateInvariants(Validator.java:1382)
   at net.sf.oval.Validator.validate(Validator.java:1308)
   at gdv.xport.feld.Feld.validateInvariants(Feld.java:623)
   at gdv.xport.feld.Feld.validate(Feld.java:605)
   at gdv.xport.feld.AlphaNumFeld.validate(AlphaNumFeld.java:161)
   at gdv.xport.feld.Feld.validate(Feld.java:601)
   at gdv.xport.feld.Satznummer.validate(Satznummer.java:232)
   at gdv.xport.feld.Feld.isValid(Feld.java:583)
   at gdv.xport.feld.Feld.isInvalid(Feld.java:592)
   at gdv.xport.satz.Teildatensatz.getSatznummer(Teildatensatz.java:146)
   at gdv.xport.satz.Teildatensatz.toShortString(Teildatensatz.java:589)
   at gdv.xport.satz.Teildatensatz.findFeld(Teildatensatz.java:352)
   at gdv.xport.satz.Teildatensatz.getFeld(Teildatensatz.java:343)
   at gdv.xport.satz.Satz.findFeld(Satz.java:620)
   at gdv.xport.satz.Satz.getFeld(Satz.java:614)
   at gdv.xport.satz.Vorsatz.getErstellungsZeitraumBis(Vorsatz.java:229)
   at gdv.xport.satz.Vorsatz.setErstellungsZeitraumVon(Vorsatz.java:214)
   at gdv.xport.Datenpaket.setErstellungsDatumVon(Datenpaket.java:592)
   at gdv.xport.Datenpaket.<init>(Datenpaket.java:75)
   at gdv.xport.Datenpaket.<init>(Datenpaket.java:62)
   at Main.main(Main.java:5)
   at static root method.(Unknown Source)
...

not providing any indication about the reason the said method is unresolved (in this case the absence of org/mozilla/javascript/Scriptable from the classpath.

#6245 was meant to address this but it looks like there are cases that still escape.

The issue seems to be caused when Graal ignores NoClassDefFoundErrors in

if (e.getCause() instanceof LinkageError || e.getCause() instanceof IllegalAccessError) {
/*
* Ignore LinkageError if thrown from eager resolution attempt. This is usually
* followed by a call to ConstantPool.lookupType() which should return an
* UnresolvedJavaType which we know how to deal with.
*/

this results in the eager resolution failure to not get logged as the cause of the UnresolvedElement.

cc @cstancu

@knuspertante
Copy link

Hey @zakkak

I'm back in this game... Unfortunately since I updated some dependencies and restructure my project I'm no longer able to build it with native-image.

I use the same dependency (gdv.xport at version 6.5.0 now). In a small example like your reproducer (https://github.com/zakkak/mandrel/tree/2023-04-27-fix-6253) all works fine but in a larger project like described in #5711 it fails.

To build your reproducer I changed the following things:

  • add org.apache.commons as dependency
 <dependency>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-jexl3</artifactId>
                    <version>3.2.1</version>
                    <exclusions>
                        <exclusion>
                            <groupId>commons-logging</groupId>
                            <artifactId>commons-logging</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
  • build native image with --initialize-at-build-time=net.sf.oval.ogn.ObjectGraphNavigatorJXPathImpl\,
    net.sf.oval.expression\,org.apache.logging.log4j.util.OsgiServiceLocator
native-image \
  --no-fallback \
  -H:+ReportExceptionStackTraces \
  --link-at-build-time \
  --initialize-at-build-time=net.sf.oval.ogn.ObjectGraphNavigatorJXPathImpl\\,\
net.sf.oval.expression\\,org.apache.logging.log4j.util.OsgiServiceLocator \
  -jar target/reproducer-1.0-SNAPSHOT.jar

Errror message:

Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: gdv.xport.feld.Feld.getInhalt(). This error is reported at image build time because class de.j21p.pandora.core.adapter.input.InputGdvXport is registered for linking at image build time by command line
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:298)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedMethod(SharedGraphBuilderPhase.java:288)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedInvoke(SharedGraphBuilderPhase.java:244)

Now I have some trouble... Is it possible to get your pr compiled on my machine? FYI: I didn't compile graalvm by myself for now. Or to get any other support by you?

@zakkak
Copy link
Collaborator Author

zakkak commented May 10, 2023

Hi @knuspertante for building GraalVM from source you may refer to https://github.com/oracle/graal/tree/master/vm#readme

In short:

git clone https://github.com/graalvm/mx
git clone https://github.com/zakkak/mandrel --branch 2023-04-27-fix-6253 graal
cd graal/vm
../../mx/mx fetch-jdk --java-distribution labsjdk-ce-17
export JAVA_HOME=...
../../mx/mx --env ni-ce build

@knuspertante
Copy link

Hi @knuspertante for building GraalVM from source you may refer to https://github.com/oracle/graal/tree/master/vm#readme

In short:

git clone https://github.com/graalvm/mx
git clone https://github.com/zakkak/mandrel --branch 2023-04-27-fix-6253 graal
cd graal/vm
../../mx/mx fetch-jdk --java-distribution labsjdk-ce-17
export JAVA_HOME=...
../../mx/mx --env ni-ce build

@zakkak thanks a lot! You are my hero ;-)

@zakkak
Copy link
Collaborator Author

zakkak commented May 31, 2023

As discussed in #6507 (comment)

The only real solution for this problem requires extensive JVMCI changes: we would need to preserve resolution and linking errors via JVMCI, where they are currently just ignored.

zakkak added a commit to zakkak/mandrel that referenced this issue Jun 2, 2023
zakkak added a commit to zakkak/mandrel that referenced this issue Jun 2, 2023
Works around oracle#6253 till a proper JVCMI fix is available.

Closes: oracle#6253
zakkak added a commit to zakkak/mandrel that referenced this issue Jun 2, 2023
Works around oracle#6253 till a proper JVCMI fix is available.

Closes: oracle#6253
zakkak added a commit to zakkak/mandrel that referenced this issue Jun 2, 2023
Works around oracle#6253 till a proper JVCMI fix is available.

Closes: oracle#6253
zakkak added a commit to zakkak/mandrel that referenced this issue Jun 7, 2023
Works around oracle#6253 till a proper JVCMI fix is available.

Closes: oracle#6253
@zakkak
Copy link
Collaborator Author

zakkak commented Jun 7, 2023

I have tested this with GraalVM for JDK 17 (23.0.0-dev), GraalVM for JDK 20 (23.0.0-dev) and GraalVM for JDK 21 (23.1.0-dev) and it looks like this issue is no longer a valid one. The actually unresolved type is properly reported.

The corresponding error messages for each version are:

GraalVM for JDK 17

Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing org.apache.logging.log4j.core.config.plugins.util.ResolverUtil.findInPackage(ResolverUtil.java:177) 
Parsing context:
   at org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.loadFromPackage(PluginRegistry.java:225)
   at org.apache.logging.log4j.core.config.plugins.util.PluginManager.collectPlugins(PluginManager.java:152)
   at org.apache.logging.log4j.core.pattern.PatternParser.<init>(PatternParser.java:132)
   at org.apache.logging.log4j.core.layout.PatternLayout.createPatternParser(PatternLayout.java:251)
   at org.apache.logging.log4j.core.layout.PatternLayout$SerializerBuilder.build(PatternLayout.java:473)
   at org.apache.logging.log4j.core.layout.PatternLayout.<init>(PatternLayout.java:140)
   at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:770)
   at org.apache.logging.log4j.core.config.AbstractConfiguration.setToDefault(AbstractConfiguration.java:723)
   at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:47)
   at org.apache.logging.log4j.core.LoggerContext.<init>(LoggerContext.java:95)
   at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:254)
   at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getDefault(ClassLoaderContextSelector.java:266)
   at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:134)
   at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:123)
   at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:117)
   at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:150)
   at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
   at org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
   at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:599)
   at gdv.xport.satz.Nachsatz.<clinit>(Nachsatz.java:52)
   at static root method.(Unknown Source)

	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:149)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:178)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureFlowsGraphCreated(MethodTypeFlow.java:152)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.getOrCreateMethodFlowsGraphInfo(MethodTypeFlow.java:110)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultSpecialInvokeTypeFlow.lambda$onObservedUpdate$0(DefaultSpecialInvokeTypeFlow.java:63)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.LightImmutableCollection.forEach(LightImmutableCollection.java:90)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultSpecialInvokeTypeFlow.onObservedUpdate(DefaultSpecialInvokeTypeFlow.java:62)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:583)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis$1.run(PointsToAnalysis.java:474)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:187)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:171)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved type during parsing: org.osgi.framework.FrameworkUtil. This error is reported at image build time because class org.apache.logging.log4j.core.config.plugins.util.ResolverUtil is registered for linking at image build time by command line
	at parsing org.apache.logging.log4j.core.config.plugins.util.ResolverUtil.loadImplementationsInBundle(ResolverUtil.java:282)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2536)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:169)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3414)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.iterateBytecodesForBlock(SharedGraphBuilderPhase.java:712)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3366)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3208)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1134)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.build(SharedGraphBuilderPhase.java:152)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1026)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:97)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:114)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:434)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:146)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.parseGraph(AnalysisMethod.java:819)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsedHelper(AnalysisMethod.java:784)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:767)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.lookupEncodedGraph(InlineBeforeAnalysisGraphDecoder.java:120)
	at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.doInline(PEGraphDecoder.java:1190)
	at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.tryInline(PEGraphDecoder.java:1173)
	at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.trySimplifyInvoke(PEGraphDecoder.java:1028)
	at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.handleInvoke(PEGraphDecoder.java:982)
	at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.GraphDecoder.processNextNode(GraphDecoder.java:871)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.processNextNode(InlineBeforeAnalysisGraphDecoder.java:186)
	at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.GraphDecoder.decode(GraphDecoder.java:600)
	at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.decode(PEGraphDecoder.java:854)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysis.decodeGraph(InlineBeforeAnalysis.java:77)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:193)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:583)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:165)
	... 15 more
Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved type during parsing: org.osgi.framework.FrameworkUtil. This error is reported at image build time because class org.apache.logging.log4j.core.config.plugins.util.ResolverUtil is registered for linking at image build time by command line
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:521)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:515)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedType(SharedGraphBuilderPhase.java:407)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedMethod(SharedGraphBuilderPhase.java:435)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedInvoke(SharedGraphBuilderPhase.java:338)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1680)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1655)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5331)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3406)
	... 44 more

By the log message Discovered unresolved type during parsing: org.osgi.framework.FrameworkUtil one can see that org.osgi.framework.FrameworkUtil is not being resolved. The reason for this is that it is not on the classpath, which is easily confirmed with mvn dependency:tree| grep osgi

GraalVM for JDK 20 and GraalVM for JDK 21

Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing org.apache.logging.log4j.core.pattern.JAnsiTextRenderer.<clinit>(JAnsiTextRenderer.java:92) 
Parsing context:
   at static root method.(Unknown Source)

	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:149)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:184)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureFlowsGraphCreated(MethodTypeFlow.java:153)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.getOrCreateMethodFlowsGraphInfo(MethodTypeFlow.java:111)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultAnalysisPolicy.staticRootMethodGraph(DefaultAnalysisPolicy.java:199)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis.lambda$addRootMethod$0(PointsToAnalysis.java:316)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis$2.run(PointsToAnalysis.java:494)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:187)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:171)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: com.oracle.graal.pointsto.util.AnalysisError: parsing had failed in another thread
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisError.shouldNotReachHere(AnalysisError.java:173)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsedHelper(AnalysisMethod.java:809)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:781)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:185)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:605)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:167)
	... 13 more
Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved type during parsing: org.fusesource.jansi.AnsiRenderer$Code. This error is reported at image build time because class org.apache.logging.log4j.core.pattern.JAnsiTextRenderer is registered for linking at image build time by command line.
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:546)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:540)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedType(SharedGraphBuilderPhase.java:432)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedNewObjectArray(SharedGraphBuilderPhase.java:294)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genNewObjectArray(BytecodeParser.java:4627)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5346)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3408)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.iterateBytecodesForBlock(SharedGraphBuilderPhase.java:737)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3368)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3210)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1136)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.build(SharedGraphBuilderPhase.java:161)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1028)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:97)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:115)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:434)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:146)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.parseGraph(AnalysisMethod.java:833)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsedHelper(AnalysisMethod.java:798)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:781)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.fieldfolding.StaticFinalFieldFoldingNodePlugin.handleLoadStaticField(StaticFinalFieldFoldingNodePlugin.java:97)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4854)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4825)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5335)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3408)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.iterateBytecodesForBlock(SharedGraphBuilderPhase.java:737)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3368)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3210)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1136)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.build(SharedGraphBuilderPhase.java:161)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1028)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:97)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:115)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:434)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:146)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.parseGraph(AnalysisMethod.java:833)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsedHelper(AnalysisMethod.java:798)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:781)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.lookupEncodedGraph(InlineBeforeAnalysisGraphDecoder.java:121)
	at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.doInline(PEGraphDecoder.java:1169)
	at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.tryInline(PEGraphDecoder.java:1152)
	at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.trySimplifyInvoke(PEGraphDecoder.java:1007)
	at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.handleInvoke(PEGraphDecoder.java:961)
	at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.GraphDecoder.processNextNode(GraphDecoder.java:905)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.processNextNode(InlineBeforeAnalysisGraphDecoder.java:193)
	at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.GraphDecoder.decode(GraphDecoder.java:634)
	at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.decode(PEGraphDecoder.java:854)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysis.decodeGraph(InlineBeforeAnalysis.java:76)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:194)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:605)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:167)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureFlowsGraphCreated(MethodTypeFlow.java:153)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.getOrCreateMethodFlowsGraphInfo(MethodTypeFlow.java:111)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultStaticInvokeTypeFlow.lambda$update$0(DefaultStaticInvokeTypeFlow.java:67)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.LightImmutableCollection.forEach(LightImmutableCollection.java:90)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultStaticInvokeTypeFlow.update(DefaultStaticInvokeTypeFlow.java:66)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis$1.run(PointsToAnalysis.java:475)
	... 8 more

By the log message Discovered unresolved type during parsing: org.fusesource.jansi.AnsiRenderer$Code one can see that org.fusesource.jansi.AnsiRenderer$Code is not being resolved. The reason for this is that it is not on the classpath, which is easily confirmed with mvn dependency:tree| grep jansi

Note

The wording could potentially be improved since Discovered unresolved type during parsing: org.fusesource.jansi.AnsiRenderer$Code is ambiguous about whether org.fusesource.jansi.AnsiRenderer$Code is the unresolved type, or whether it is the class that was beeing parsed.

@zakkak zakkak closed this as completed Jun 7, 2023
@zakkak
Copy link
Collaborator Author

zakkak commented Jun 18, 2024

Unfortunately we are seeing this again with GraalVM for JDK 21 and master, see quarkusio/quarkus#41256 (comment)

Update: Unfortunately the existing reproducer doesn't work, so I need to create a new one to confirm the issue and further investigate.

@zakkak zakkak reopened this Jun 18, 2024
zakkak added a commit to zakkak/mandrel that referenced this issue Oct 8, 2024
Works around oracle#6253 till a proper JVCMI fix is available.
zakkak added a commit to zakkak/issue-reproducers that referenced this issue Oct 9, 2024
@zakkak
Copy link
Collaborator Author

zakkak commented Oct 9, 2024

The new reproducer is:

cd /tmp
git clone --branch 2024-10-09-oracle-graal-6253-reproducer https://github.com/zakkak/issue-reproducers reproducers
cd reproducers
mvn package
# run in JVM
java \
  -jar target/reproducer-1.0-SNAPSHOT.jar
# generate native-image with --link-at-build-time
native-image \
  --no-fallback \
  --link-at-build-time  \
  -H:+ReportExceptionStackTraces \
  -jar target/reproducer-1.0-SNAPSHOT.jar
# Build fails

zakkak added a commit to zakkak/mandrel that referenced this issue Oct 10, 2024
Works around oracle#6253 till a proper JVCMI fix is available.
zakkak added a commit to zakkak/mandrel that referenced this issue Nov 18, 2024
Works around oracle#6253 till a proper JVCMI fix is available.
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.

3 participants