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.43k stars 125 forks source link

Compilation Fails when using .graphqlconfig and implicitly defining a schema #321

Closed amgunden closed 3 years ago

amgunden commented 3 years ago

Describe the bug Compiling fails when a .graphqlconfig is added and a schema is defined implicitly with the operation roots being named "Query" and "Mutation"

To Reproduce Steps to reproduce the behavior:

  1. Start with the manifold-sample-graphql-app
  2. Add a new .graphqlconfig and define the GraphQL files. I used the following: { "name": "GraphQLSchema", "schema": ["./movies.graphql", "./queries.graphql"] }
  3. Remove the schema declaration in movies.graphql and rename QueryRoot to Query and MutationRoot to Mutation
  4. In queries.graphql, change the Extension Query to extend Query instead of QueryRoot
  5. In Setup.java, rename QueryRoot.class to Query.class and MutationRoot.class to Mutation.class

Expected behavior Compiling succeeds when a schema is defined implicitly

Desktop (please complete the following information):

Additional context I originally came across this when I was updating a project with multiple schemas to the latest Manifold version. I then tested it in the manifold-sample-graphql-app project and found the same compiler error. I tried to do a little debugging and it seems like the issue arises in GqlScope.ensureSchemaDefinitionAssigned(). Manifold tries to get the fqnForFile but can't find a match in the PathCache. See the following screenshots:

IFile schemaFile: IFileSchemaFile

PathCache: reverseMap

Resulting fqnForFile: fqnForFile

Stack trace

Clearing build system data... Executing pre-compile tasks... Loading Ant configuration... Running Ant tasks... Build: waiting for debugger connection on port 5005 Cleaning output directories... Running 'before' tasks Checking sources Copying resources... [manifold-sample-graphql-app] Parsing java... [manifold-sample-graphql-app] java: compiler message file broken: key=compiler.misc.msg.bug arguments=11.0.12, {1}, {2}, {3}, {4}, {5}, {6}, {7} java: java.lang.NullPointerException java: at manifold.graphql.type.GqlScope.ensureSchemaDefinitionAssigned(GqlScope.java:156) java: at manifold.graphql.type.GqlScope.getSchemaDefinition(GqlScope.java:141) java: at manifold.graphql.type.GqlParentType.getRoot(GqlParentType.java:635) java: at manifold.graphql.type.GqlParentType.addQueryType(GqlParentType.java:282) java: at manifold.graphql.type.GqlParentType.addInnerOperations(GqlParentType.java:261) java: at manifold.graphql.type.GqlParentType.render(GqlParentType.java:119) java: at manifold.graphql.type.GqlManifold.contribute(GqlManifold.java:131) java: at manifold.graphql.type.GqlManifold.contribute(GqlManifold.java:35) java: at manifold.api.type.ResourceFileTypeManifold.contribute(ResourceFileTypeManifold.java:417) java: at manifold.internal.host.SimpleModule.compoundProduce(SimpleModule.java:166) java: at manifold.internal.host.SimpleModule.lambda$produceFile$0(SimpleModule.java:139) java: at manifold.internal.javac.SourceSupplier.getSource(SourceSupplier.java:50) java: at manifold.internal.javac.GeneratedJavaStubFileObject.lambda$new$0(GeneratedJavaStubFileObject.java:40) java: at manifold.util.concurrent.LocklessLazyVar$1.init(LocklessLazyVar.java:91) java: at manifold.util.concurrent.LocklessLazyVar.get(LocklessLazyVar.java:40) java: at manifold.internal.javac.GeneratedJavaStubFileObject.getCharContent(GeneratedJavaStubFileObject.java:101) java: at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.readSourceFile(JavaCompiler.java:817) java: at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.readSourceFile(JavaCompiler.java:797) java: at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.lambda$new$0(JavaCompiler.java:356) java: at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:363) java: at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:291) java: at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:642) java: at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1326) java: at jdk.compiler/com.sun.tools.javac.code.ClassFinder.loadClass(ClassFinder.java:433) java: at manifold.internal.javac.ManClassFinder_9.loadClass(ManClassFinder_9.java:66) java: at jdk.compiler/com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:1996) java: at jdk.compiler/com.sun.tools.javac.comp.Resolve.findIdentInPackageInternal(Resolve.java:2386) java: at jdk.compiler/com.sun.tools.javac.comp.Resolve.findIdentInPackage(Resolve.java:2374) java: at jdk.compiler/com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3718) java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3603) java: at manifold.internal.javac.ManAttr_9.visitSelect(ManAttr_9.java:126) java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2114) java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655) java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribImportQualifier(Attr.java:390) java: at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.doImport(TypeEnter.java:410) java: at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.resolveImports(TypeEnter.java:364) java: at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.runPhase(TypeEnter.java:321) java: at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.doCompleteEnvs(TypeEnter.java:282) java: at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:251) java: at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:198) java: at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:1259) java: at jdk.compiler/com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:316) java: at manifold.internal.javac.ManResolve.isAccessible(ManResolve.java:134) java: at jdk.compiler/com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:299) java: at jdk.compiler/com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:1997) java: at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:583) java: at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:560) java: at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1066) java: at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:937) java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104) java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147) java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100) java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94) java: at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:238) java: at org.jetbrains.jps.incremental.java.JavaBuilder.lambda$compileJava$2(JavaBuilder.java:514) java: at org.jetbrains.jps.incremental.java.JavaBuilder.invokeJavac(JavaBuilder.java:560) java: at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:512) java: at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:355) java: at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:280) java: at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:234) java: at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1485) java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1123) java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1268) java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1088) java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:854) java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:441) java: at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:190) java: at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:132) java: at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:318) java: at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:146) java: at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:218) java: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) java: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) java: at java.base/java.lang.Thread.run(Thread.java:829) java: Compilation failed: internal java compiler error Errors occurred while compiling module 'manifold-sample-graphql-app' javac 11.0.12 was used to compile java sources Finished, saving caches... Compilation failed: errors: 1; warnings: 0 Executing post-compile tasks... Loading Ant configuration... Running Ant tasks... Synchronizing output directories... 11/16/21, 2:12 PM - Build completed with 1 error and 0 warnings in 3 min, 26 sec

Let me know if I am missing anything and thanks in advance for any help you can provide.

rsmckinney commented 3 years ago

Fix available in release 2021.1.31. Thanks for reporting this!

amgunden commented 3 years ago

Great, works for me. Thank you!