manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.4k stars 125 forks source link

GraalVM maven build error #612

Closed sahoomanu closed 2 months ago

sahoomanu commented 2 months ago

Describe the bug

Getting compilation error while building

[INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project ims-rpa: Compilation failure: Compilation failure: [ERROR] /java/net/URL.java:[21,29] cannot find symbol [ERROR] symbol: class UrlDeserializedState [ERROR] location: package java.net [ERROR] /java/net/URL.java:[264,35] package jdk.internal.misc does not exist [ERROR] /java/lang/Object.java:[6,30] package jdk.internal.vm.annotation does not exist [ERROR] /java/lang/Object.java:[10,30] package jdk.internal.vm.annotation does not exist [ERROR] /java/lang/Object.java:[14,30] package jdk.internal.vm.annotation does not exist [ERROR] /java/lang/Object.java:[21,30] package jdk.internal.vm.annotation does not exist [ERROR] /java/lang/Object.java:[28,30] package jdk.internal.vm.annotation does not exist [ERROR] /java/lang/Object.java:[32,30] package jdk.internal.vm.annotation does not exist [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

To Reproduce Steps to reproduce the behavior: 1.include annotation processor 2. 3.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem (drag/drop them here).

Desktop (please complete the following information):

Additional context Add any other context about the problem here. pom.txt

Stack trace Please include a stack trace if applicable

rsmckinney commented 2 months ago

Are you compiling from within IntelliJ or from a command line?

rsmckinney commented 2 months ago

If from IntelliJ, make sure your project SDK is setup correctly. Similarly, if building from the command line ensure the right JDK is in context.

sahoomanu commented 2 months ago

Thanks, I am building from command line. GraalVM 21 is set as JDK . looks like conflicting with another dependency library, not sure. able to build the examples given . :(

rsmckinney commented 2 months ago

Is your project available for cloning/debugging? If not, can you provide more details to reproduce the problem? Thanks

sahoomanu commented 2 months ago

no , it is working fine with IntelliJ plugin, not working with maven

--enable-preview --add-exports java.base/jdk.internal.vm=ALL-UNNAMED -Xplugin:Manifold

i tried this , still having issue

rsmckinney commented 2 months ago

I’ll need to reproduce the issue you’re having to make a diagnosis. If your project is not accessible to me, can you refine the problem to a minimum sample project? That help a lot.

cpmooney commented 2 months ago

I ran into something very similar myself just now. I was following the documentation to create a toy extension. Similar setup to what's listed at the top of this. I am running from IntelliJ and am using java 22. It's completely barebones -- the only thing I have is from the example I was trying to follow.

Here is my repo: https://github.com/cpmooney/example-manifold-extension

The example I was trying to follow along with was here: https://github.com/manifold-systems/manifold/tree/master/manifold-deps-parent/manifold-ext#maven

Here is the output from my compiler:

Executing pre-compile tasks… Running 'before' tasks Checking sources Copying resources... [manifold] Parsing java… [manifold] java: package jdk.internal.vm.annotation does not exist java: package jdk.internal.vm.annotation does not exist java: package jdk.internal.vm.annotation does not exist java: package jdk.internal.vm.annotation does not exist java: package jdk.internal.vm.annotation does not exist java: package jdk.internal.vm.annotation does not exist Checking dependencies… [manifold] Dependency analysis found 0 affected files Errors occurred while compiling module 'manifold' javac 22.0.1 was used to compile java sources Finished, saving caches… Compilation failed: errors: 7; warnings: 1 Executing post-compile tasks… Synchronizing output directories… 8/14/2024 11:58 AM - Build completed with 7 errors and 1 warning in 2 sec, 414 ms

rsmckinney commented 2 months ago

Hi @cpmooney. I see you've fixed the original issue by adding <maven.compiler.source/target> to your pom file. But your exention for Thing will not work because extensions are exclusive to classes you otherwise cannot modify directly. Since Thing is non-generated and local to the same module in which the extension class is defined, the extension will have no effect on Thing, compiler warnings indicate this.

If instead you define Thing in a separate module, since it compiles separately from your extension, the extension methods will work as expected. You can also add extensions to Java runtime classes such as String and any other class accessible to your project.