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

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

Open
tinca opened this issue Oct 11, 2018 · 10 comments

Comments

@tinca
Copy link

tinca commented Oct 11, 2018

Hi,

I try to get an answer to this issue:
cincheo/jsweet#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
Copy link
Collaborator

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

@tinca
Copy link
Author

tinca commented Oct 13, 2018

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.

@lgrignon
Copy link
Collaborator

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
Copy link
Author

tinca commented Oct 13, 2018

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
Copy link
Author

tinca commented Oct 18, 2018

Any advice how to resolve this?

@schaumb
Copy link
Collaborator

schaumb commented Oct 18, 2018

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
Copy link
Author

tinca commented Oct 18, 2018

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
Copy link
Collaborator

lgrignon commented Apr 4, 2020

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

@tinca
Copy link
Author

tinca commented Apr 4, 2020

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
Copy link
Collaborator

lgrignon commented Apr 4, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants