j4ts icon indicating copy to clipboard operation
j4ts copied to clipboard

com.sun.tools.javac.jvm.ClassReader$BadClassFile: bad class file when using j4ts

Open tinca opened this issue 7 years ago • 10 comments

Hi,

I try to get an answer to this issue: https://github.com/cincheo/jsweet/issues/491

My gradle build file contains:

buildscript {
...
    dependencies {
        classpath('org.jsweet:jsweet-gradle-plugin:2.2.0-SNAPSHOT') { //
            transitive = true }
    }
}
...
dependencies {
    compile group: 'org.jsweet', name: 'jsweet-core', version:'6-SNAPSHOT'
    compile group: 'org.jsweet', name: 'jsweet-transpiler', version:'2.2.0-SNAPSHOT'
    compile group: 'org.jsweet.candies.ext', name: 'angular', version:'1.4.0-SNAPSHOT'
    compile group: 'org.jsweet.candies.ext', name: 'angular-route', version:'1.2.0-SNAPSHOT'
    compile group: 'org.jsweet.candies.trusted', name: 'es6-promise', version:'0.0.0-SNAPSHOT'
    compile 'org.jheaps:jheaps:0.9'
    compile group: 'org.jsweet', name: 'j4ts', version:'0.5.0'
}

However j4ts pom.xml defines jsweet 2.0.0. I tried to change that to 2.2.0 in a fork, but that gives a lot of errors. I tried to change jsweet (and plugin) to 2.0.0 to no avail. It seems j4ts is not in sync with current jsweet.

I am keen in testing jsweet on a real project e.g. transpiling JGraphT and if that is successful my project that builds on that, too.

Thanks!

tinca avatar Oct 11 '18 07:10 tinca

Hello, please use 2.2.0-SNAPSHOT and j4ts 0.6.0-SNAPSHOT and post here if it's better or worse.

lgrignon avatar Oct 13 '18 14:10 lgrignon

Hi,

Thank you for looking into it! This is what I get:

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':jsweet'.

Could not resolve all files for configuration ':compileClasspath'. Could not resolve org.jsweet:j4ts:0.6.0-SNAPSHOT. Required by: project : > Could not resolve org.jsweet:j4ts:0.6.0-SNAPSHOT. > Could not get resource 'http://repository.jsweet.org/artifactory/libs-release-local/org/jsweet/j4ts/0.6.0-SNAPSHOT/j4ts-0.6.0-SNAPSHOT.pom'. > Could not GET 'http://repository.jsweet.org/artifactory/libs-release-local/org/jsweet/j4ts/0.6.0-SNAPSHOT/j4ts-0.6.0-SNAPSHOT.pom'. Received status code 409 from server: Conflict

I am using these repos:

maven { url "http://repository.jsweet.org/artifactory/libs-release-local" }
maven { url "http://repository.jsweet.org/artifactory/libs-snapshot-local" }

Can't seem to find in the snapshot repo by using a browser, although the http status code is not a simple missing (404) resource.

tinca avatar Oct 13 '18 18:10 tinca

Can you find the jar in the UI at http://repository.jsweet.org/artifactory/ ? Maybe it has never been deployed before. If you find it, please clean your local maven repo, otherwise you can clone j4ts + deploy

lgrignon avatar Oct 13 '18 19:10 lgrignon

Search for j4ts-0.5.0*.jar finds 2 artifacts in realese and snapshot local repos. Nothing is returned for j4ts-0.6.0*.jar.

Here is what I get during build attempts.

  1. changes to pom:
  • jsweet.transpiler.version -> 2.2.0
  • jsweet-core -> 5-SNAPSHOT
  • jsweet-maven-plugin -> 2.0.0 Build is OK, No test failure Among logged lines there is something that may be worth noting:

2018-10-13 22:26:19.019 INFO JSweetTranspiler:1146 - scanning /Users/zkuti/projects-new/j4ts/src/main/java/javaemul/internal/NumberHelper.java... com.sun.tools.javac.jvm.ClassReader$BadClassFile: bad class file: /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/ct.sym(META-INF/sym/rt.jar/java/util/Vector$ListItr.class) undeclared type variable: E Please remove or make sure it appears in the correct subdirectory of the classpath. at com.sun.tools.javac.jvm.ClassReader.badClassFile(ClassReader.java:357) at com.sun.tools.javac.jvm.ClassReader.findTypeVar(ClassReader.java:948) at com.sun.tools.javac.jvm.ClassReader.sigToType(ClassReader.java:653) at com.sun.tools.javac.jvm.ClassReader.sigToType(ClassReader.java:717) at com.sun.tools.javac.jvm.ClassReader.sigToType(ClassReader.java:639) at com.sun.tools.javac.jvm.ClassReader.readType(ClassReader.java:562) at com.sun.tools.javac.jvm.ClassReader$13.read(ClassReader.java:1158) at com.sun.tools.javac.jvm.ClassReader.readAttrs(ClassReader.java:1381) at com.sun.tools.javac.jvm.ClassReader.readMemberAttrs(ClassReader.java:1371) at com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:2044)

  1. as 1, but with
  • jsweet-maven-plugin -> 2.2.0

org.apache.maven.plugin.MojoFailureException: transpilation failed with 18 error(s) Build fails.

  1. as 1, but with
  • jsweet-core -> 6-SNAPSHOT Build fails.

2018-10-13 22:25:15.015 ERROR output:55 - no suitable method found for set(java.lang.Double[],int) method def.js.Uint8Array.set(double,double) is not applicable (argument mismatch; java.lang.Double[] cannot be converted to double) method def.js.Uint8Array.set(def.js.Uint8Array,double) is not applicable (argument mismatch; java.lang.Double[] cannot be converted to def.js.Uint8Array) at /Users/zkuti/projects-new/j4ts/src/main/java/java/nio/ByteOrder.java(37) 2018-10-13 22:25:15.015 ERROR JSweetTranspiler:83 - /Users/zkuti/projects-new/j4ts/src/main/java/java/nio/ByteOrder.java:37: error: no suitable method found for set(java.lang.Double[],int) uint8Array.set(new Double[]{ (double)0xAA, (double) 0xBB }, 0); ^ method def.js.Uint8Array.set(double,double) is not applicable (argument mismatch; java.lang.Double[] cannot be converted to double) method def.js.Uint8Array.set(def.js.Uint8Array,double) is not applicable (argument mismatch; java.lang.Double[] cannot be converted to def.js.Uint8Array) 2018-10-13 22:25:15.015 ERROR output:55 - incompatible types: java.lang.Double[] cannot be converted to def.js.Int8Array at /Users/zkuti/projects-new/j4ts/src/main/java/java/nio/ByteBuffer.java(443) 2018-10-13 22:25:15.015 ERROR JSweetTranspiler:83 - /Users/zkuti/projects-new/j4ts/src/main/java/java/nio/ByteBuffer.java:443: error: incompatible types: java.lang.Double[] cannot be converted to def.js.Int8Array bytes.set((Double[]) any(Lang.array(array).slice(offset, offset + length)));

So I may try the artifact of the first one. How can I do that?

tinca avatar Oct 13 '18 20:10 tinca

Any advice how to resolve this?

tinca avatar Oct 18 '18 11:10 tinca

The first if it's OK, then it is OK. " 2018-10-13 22:26:19.019 INFO JSweetTranspiler:1146 - scanning /Users/zkuti/projects-new/j4ts/src/main/java/javaemul/internal/NumberHelper.java... com.sun.tools.javac.jvm.ClassReader$BadClassFile: bad class file: /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/ct.sym(META-INF/sym/rt.jar/java/util/Vector$ListItr.class) undeclared type variable: E Please remove or make sure it appears in the correct subdirectory of the classpath. " this means the rt.jar is in the classpath, but It is OK, this not leading any problem in runtime.

The second: " jsweet-maven-plugin -> 2.2.0 org.apache.maven.plugin.MojoFailureException: transpilation failed with 18 error(s) Build fails. " I fixed it locally these errors, but not pull-requested yet. These issues will fix after the change-over (2.2.0) has done.

The third: " jsweet-core -> 6-SNAPSHOT Build fails. " I think I fixed these locally too. I will make a PR for this one either.

Any advice how to resolve this?

schaumb avatar Oct 18 '18 11:10 schaumb

Hi Bela, For the first: this message also appeared when I tried to transpile JGraphT and do not remember if the build itself failed or not. Now repeated, message is there, but build seems to be fine, so can try the next steps. Thanks for the other two too!

tinca avatar Oct 18 '18 14:10 tinca

Hello @tinca Did you solve your issue? Sorry we did not answer

lgrignon avatar Apr 04 '20 09:04 lgrignon

In lack of time I left my experiments unfinished. I hope to revive them in the near future, so I wish the necessary packages will all be available and smoothly work together at that time.

tinca avatar Apr 04 '20 09:04 tinca

I hope J4TS will be available for JSweet 3 / Java 11 at that time, but it will require contributors or more time for us (maintainers) so 🤞 :)

lgrignon avatar Apr 04 '20 10:04 lgrignon