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

Manifold cannot compile or run as "Test Sources" #87

Closed
sporkisfaster opened this issue May 14, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@sporkisfaster
Copy link

commented May 14, 2019

Describe the bug
If the directory that Manifold compiles/runs from is marked as a "Test Sources" folder. You will get a ClassCastException:
Error:java: java.lang.ClassCastException: manifold.api.fs.jar.JarEntryFileImpl cannot be cast to manifold.api.fs.jar.JarEntryDirectoryImpl

When used as regular source root folder, compilation/run occurs as normal.

To Reproduce
Steps to reproduce the behavior:

  1. Create a java class under src/test/java marked as Test Sources Root
  2. Utilize manifold (in my case it was with a .JSON manifold in test resources folder)
  3. Compile test sources

Expected behavior
Class(es) compile/run as they would in regular source root folders.

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

Desktop (please complete the following information):

  • OS Type & Version: Mac OS 10.14.5 (18F132)
  • Java/JDK version: 8u212
  • IntelliJ IDEA version: 2019.1.2
  • Manifold version: 0.65
  • Manifold IntelliJ plugin version: 0.65

Stack trace

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:testCompile (default-cli) on project backend: Fatal error compiling
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1140)
    at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:181)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 21 more
Caused by: org.codehaus.plexus.compiler.CompilerException: java.lang.ClassCastException: manifold.api.fs.jar.JarEntryFileImpl cannot be cast to manifold.api.fs.jar.JarEntryDirectoryImpl
    at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:173)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1129)
    ... 24 more
Caused by: java.lang.RuntimeException: java.lang.ClassCastException: manifold.api.fs.jar.JarEntryFileImpl cannot be cast to manifold.api.fs.jar.JarEntryDirectoryImpl
    at com.sun.tools.javac.main.Main.compile(Main.java:559)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
    at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
    ... 26 more
Caused by: java.lang.ClassCastException: manifold.api.fs.jar.JarEntryFileImpl cannot be cast to manifold.api.fs.jar.JarEntryDirectoryImpl
    at manifold.api.fs.jar.JarEntryDirectoryImpl.getOrCreateDirectory(JarEntryDirectoryImpl.java:43)
    at manifold.api.fs.jar.JarFileDirectoryImpl.processJarEntry(JarFileDirectoryImpl.java:110)
    at manifold.api.fs.jar.JarFileDirectoryImpl.<init>(JarFileDirectoryImpl.ja```


@rsmckinney

This comment has been minimized.

Copy link
Member

commented May 14, 2019

Can you provide a project on github that demonstrates this? I can't reproduce this locally.

One thing. If you are developing your own type manifold and attempt to create test sources in the same module, you'll have problems. Java services are such that they must be precompiled, thus tests that exercise a type manifold must reside in a separate module with a dependency on the type manifold module. Not sure if this is your use-case, but something to consider.

@sporkisfaster

This comment has been minimized.

Copy link
Author

commented May 15, 2019

rsmckinney added a commit that referenced this issue May 16, 2019

Manifold core change (#87)
- apparently a jar file can have both a file entry and a directory entry as siblings with the same exact name, accounting for that

@rsmckinney rsmckinney added the bug label May 16, 2019

@rsmckinney

This comment has been minimized.

Copy link
Member

commented May 16, 2019

Problem wasn't so much test v. main sources as it was processing a specific jar file as part of building test sourcers/resources. The sample project you provided (thanks!) has a selenium test dependency jar (I don't recall the exact name of it) and it had in its META-INF/versions both a directory entry named "9" and a file entry named "9". My jar file abstraction did not account for this surprise. The fix is available in release 0.68-alpha of both manifold and the ij plugin (plugin available when jetbrains approves the release, probably within a day or two).

@sporkisfaster

This comment has been minimized.

Copy link
Author

commented May 16, 2019

Aha! Thank you so much!

@rsmckinney

This comment has been minimized.

Copy link
Member

commented May 16, 2019

Fix available in release 0.68-alpha

@rsmckinney rsmckinney closed this May 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.