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

[native-image] AnalysisError$FieldNotPresentError: Field java.net.URI.string is not present on type java.lang.Object #1805

Closed
oowekyala opened this issue Nov 3, 2019 · 6 comments
Assignees

Comments

@oowekyala
Copy link

oowekyala commented Nov 3, 2019

Hi,

I'm trying to compile a native image of Jetty, and compilation fails with what looks like a bug:

Error: Field java.net.URI.string is not present on type java.lang.Object. Error encountered while analysing java.net.URI.toString() 
Parsing context:
	parsing java.util.Formatter$FormatSpecifier.printString(Formatter.java:2886)
	parsing java.util.Formatter$FormatSpecifier.print(Formatter.java:2763)
	parsing java.util.Formatter.format(Formatter.java:2508)
	parsing java.util.Formatter.format(Formatter.java:2455)
	parsing java.lang.String.format(String.java:2940)
	parsing org.eclipse.jetty.start.StartLog.log(StartLog.java:83)
	parsing org.eclipse.jetty.start.StartLog.error(StartLog.java:98)
	parsing org.eclipse.jetty.start.Main.main(Main.java:81)
	parsing com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:151)
	parsing com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186)
	parsing com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)

com.oracle.graal.pointsto.util.AnalysisError$FieldNotPresentError: Field java.net.URI.string is not present on type java.lang.Object. Error encountered while analysing java.net.URI.toString() 
Parsing context:
	parsing java.util.Formatter$FormatSpecifier.printString(Formatter.java:2886)
	parsing java.util.Formatter$FormatSpecifier.print(Formatter.java:2763)
	parsing java.util.Formatter.format(Formatter.java:2508)
	parsing java.util.Formatter.format(Formatter.java:2455)
	parsing java.lang.String.format(String.java:2940)
	parsing org.eclipse.jetty.start.StartLog.log(StartLog.java:83)
	parsing org.eclipse.jetty.start.StartLog.error(StartLog.java:98)
	parsing org.eclipse.jetty.start.Main.main(Main.java:81)
	parsing com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:151)
	parsing com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186)
	parsing com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)

	at com.oracle.graal.pointsto.util.AnalysisError.fieldNotPresentError(AnalysisError.java:142)
	at com.oracle.graal.pointsto.flow.context.object.AnalysisObject.getInstanceFieldTypeStore(AnalysisObject.java:224)
	at com.oracle.graal.pointsto.flow.context.object.AnalysisObject.getInstanceFieldFlow(AnalysisObject.java:209)
	at com.oracle.graal.pointsto.flow.LoadFieldTypeFlow$LoadInstanceFieldTypeFlow.onObservedUpdate(LoadFieldTypeFlow.java:160)
	at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:343)
	at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:385)
	at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:510)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:171)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
(truncated)

You can run our setup in the following way:

git clone --single-branch --depth=1 -b aot-fork [email protected]:oowekyala/jetty.project.git
cd jetty.project
mvn clean install -DskipTests -Dmaven.javadoc.skip # takes a while, use -T to speed it up
export GRAALVM_HOME="/path/to/your/graal"
graal/graal_compile.sh 

This occurs with the latest release of graal/ native-image

Keep up the good work!

@kaspernielsen
Copy link

I have the same problem but for a different field than java.net.URI.string with latest 19.3.0 CE.

com.oracle.graal.pointsto.util.AnalysisError$FieldNotPresentError: Field app.packed.container.Extension.context is not present on type java.lang.Object. Error encountered while analysing app.packed.container.Extension$1.setExtensionContext(app.packed.container.Extension, app.packed.container.ExtensionContext)
Parsing context:
	parsing packed.internal.container.extension.PackedExtensionContext.initialize(PackedExtensionContext.java:119)
	parsing packed.internal.container.extension.PackedExtensionContext.of(PackedExtensionContext.java:234)
	parsing packed.internal.container.PackedContainerConfiguration.useExtension(PackedContainerConfiguration.java:495)
	parsing packed.internal.container.PackedContainerConfiguration.use(PackedContainerConfiguration.java:463)
	parsing app.packed.container.Bundle.use(Bundle.java:301)
	parsing app.packed.container.BaseBundle.service(BaseBundle.java:249)
	parsing app.packed.container.BaseBundle.provideInstance(BaseBundle.java:224)
	parsing com.HelloWorld.configure(HelloWorld.java:14)
	parsing app.packed.container.Bundle.doConfigure(Bundle.java:150)
	parsing app.packed.container.Bundle$1.doConfigure(Bundle.java:59)
	parsing packed.internal.container.PackedContainerConfiguration.configure(PackedContainerConfiguration.java:162)
	parsing packed.internal.container.PackedContainerConfiguration.doBuild(PackedContainerConfiguration.java:170)
	parsing app.packed.artifact.ArtifactDriver.newArtifact(ArtifactDriver.java:130)
	parsing app.packed.artifact.App.open(App.java:177)
	parsing com.HelloWorld.main(HelloWorld.java:18)
	parsing com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:151)
	parsing com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186)
	parsing com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)

	at com.oracle.graal.pointsto.util.AnalysisError.fieldNotPresentError(AnalysisError.java:142)
	at com.oracle.graal.pointsto.flow.context.object.AnalysisObject.getInstanceFieldTypeStore(AnalysisObject.java:224)
	at com.oracle.graal.pointsto.flow.context.object.AnalysisObject.getInstanceFieldFlow(AnalysisObject.java:209)
	at com.oracle.graal.pointsto.flow.StoreFieldTypeFlow$StoreInstanceFieldTypeFlow.onObservedUpdate(StoreFieldTypeFlow.java:161)
	at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:343)
	at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:385)
	at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:511)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:171)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Error: Image build request failed with exit status 1

It will take a little cleanup to post. So let me know if you need additional code to what oowekyala has provided.

@cstancu
Copy link
Member

cstancu commented Nov 27, 2019

@oowekyala @kaspernielsen thanks for the reports. This is a side effect of the current limitations in native-image support of MethodHandles. See #772 (comment) for a detailed explanation of the underlying issue.

In the case of Jetty, the problematic code is in TypeUtil.getLocationOfClass:

 public static URI getLocationOfClass(Class<?> clazz)
    {
        URI location;

        for (MethodHandle locationMethod : LOCATION_METHODS)
        {
            try
            {
                location = (URI)locationMethod.invoke(clazz);
                if (location != null)
                {
                    return location;
                }
            }
            catch (Throwable cause)
            {
                cause.printStackTrace(System.err);
            }
        }
        return null;
    }

Although MethodHandle[] LOCATION_METHODS is effectivelly final when using --initialize-at-build-time=org.eclipse.jetty.util.TypeUtil the corresponding MethodHandles are not intrinsified.

@kaspernielsen
Copy link

Okay, is there an issue that tracks the implementation status of MethodHandle (and friends)?

@cstancu
Copy link
Member

cstancu commented Nov 28, 2019

This comment #955 (comment) is a good summary of the current status. We have some ideas about how to improve the MethodHandle support and we'll have an initial implementation soon.

@kaspernielsen
Copy link

Thanks, yeah I'm already following that issue:)

@cstancu
Copy link
Member

cstancu commented Dec 21, 2019

3a96706 should provide a better error message. The MethodHandle support still has limitations, follow the progress on the related issue that I mentioned above.

@cstancu cstancu closed this as completed Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants