j4ts / j4ts

Core Java APIs for TypeScript / JavaScript / JSweet
Apache License 2.0
97 stars 24 forks source link

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

Open tinca opened 5 years ago

tinca commented 5 years ago

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!

lgrignon commented 5 years ago

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

tinca commented 5 years ago

Hi,

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

FAILURE: Build failed with an exception.

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.

lgrignon commented 5 years ago

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

tinca commented 5 years ago

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.

  2. 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 commented 5 years ago

Any advice how to resolve this?

schaumb commented 5 years ago

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?

tinca commented 5 years ago

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!

lgrignon commented 4 years ago

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

tinca commented 4 years ago

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.

lgrignon commented 4 years ago

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 🤞 :)