Giter Site home page Giter Site logo

teavm-javac's People

Contributors

konsoletyper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

teavm-javac's Issues

Getting Sandbox example running locally

Hey @konsoletyper,
sorry to bother you again, but I've never used Java in the web context, so I don't know anything about .war, Tomcat, etc. For experienced devs the readme.md is probably sufficient, but for me it leaves a couple of questions. I'm trying to get the Sandbox example editor running locally.

I compiled via mvn package and then deployed the .war file to Apache Tomcat using the Manager UI. However as far as I can tell the war file does not contain any UI code, correct? So how do I get the UI up and running? I've seen a couple of node modules in the UI folder, and again I'm unsure what they're for? I thought the goal was to run everything in the browser, so what's the reasoning for the node components?

Sorry for my stupid questions, I'd really like to understand the concepts behind this project.

Compilation failure: Cannot find symbol 'TranslationContext'

I'm trying to compile this, but I always end up getting Compilation failures. Any idea what the reason for this is? Maybe different JDK version? I tried both 10 and 8 without luck :(

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project teavm-javac-javac: Compilation failure: Compilation failure:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project teavm-javac-javac: Compilation failure: Compilation failure:
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[93,25] cannot find symbol
[ERROR]   symbol:   class TranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[96,13] cannot find symbol
[ERROR]   symbol:   class TranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[193,44] cannot find symbol
[ERROR]   symbol:   class TranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[204,57] cannot find symbol
[ERROR]   symbol:   class TranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[981,50] cannot find symbol
[ERROR]   symbol:   class TranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[780,23] cannot find symbol
[ERROR]   symbol:   class ReferenceTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod.MemberReferenceToLambda
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[787,57] cannot find symbol
[ERROR]   symbol:   class ReferenceTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod.MemberReferenceToLambda
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[189,9] cannot find symbol
[ERROR]   symbol:   class TranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[194,9] cannot find symbol
[ERROR]   symbol:   class TranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[216,47] cannot find symbol
[ERROR]   symbol:   class TranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[267,9] cannot find symbol
[ERROR]   symbol:   class LambdaTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[267,50] cannot find symbol
[ERROR]   symbol:   class LambdaTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[372,9] cannot find symbol
[ERROR]   symbol:   class ReferenceTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[372,53] cannot find symbol
[ERROR]   symbol:   class ReferenceTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[427,17] cannot find symbol
[ERROR]   symbol:   class LambdaTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[427,59] cannot find symbol
[ERROR]   symbol:   class LambdaTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[455,17] cannot find symbol
[ERROR]   symbol:   class LambdaTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[455,59] cannot find symbol
[ERROR]   symbol:   class LambdaTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[470,9] cannot find symbol
[ERROR]   symbol:   class LambdaTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod
[ERROR] /Users/user/teavm/javac/target/langtools/langtools-53092d863cb6/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java:[470,51] cannot find symbol
[ERROR]   symbol:   class LambdaTranslationContext
[ERROR]   location: class com.sun.tools.javac.comp.LambdaToMethod

Two-dimensional arrays have flipped dimensions

When declaring a two-dimensional array and then taking the length of the respective dimensions, the dimensions are flipped.

Minimal code example:
The first dimension should have length 2 and the second length 3. However, the printed result is 3 and 2, so the reversed order.

public class Main {
    public static void main(String[] args) {
        int[][] array = new int[2][3];
        System.out.println("1. Dimension: " + array.length);
    	System.out.println("2. Dimension: " + array[0].length);
    }
}

Bridging to JavaScript results in a stack overflow

When I add the following code into the online teavm-javac interface, I get a stack overflow:

import org.teavm.jso.JSBody;

class Main {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
        
        log("TESTING BRIDGE");
    }
    
    @JSBody(params = { "message" }, script = "console.log(message)")
    private static native void log(String message);
}

Output

Message received: 0
runtime.js:414 Initializing
runtime.js:414 Initialized in 943 ms
runtime.js:414 Message received: 1
runtime.js:414 [parsing started RegularFileObject[/Main.java]]
runtime.js:414 [parsing completed 22ms]
runtime.js:414 [search path for source files: .]
runtime.js:414 [search path for class files: /stdlib,.]
runtime.js:414 [loading RegularFileObject[/stdlib/org/teavm/jso/JSBody.class]]
runtime.js:414 [loading RegularFileObject[/stdlib/java/lang/Object.class]]
runtime.js:414 [loading RegularFileObject[/stdlib/java/lang/String.class]]
runtime.js:414 [loading RegularFileObject[/stdlib/java/lang/annotation/Retention.class]]
runtime.js:414 [loading RegularFileObject[/stdlib/java/lang/annotation/RetentionPolicy.class]]
runtime.js:414 [loading RegularFileObject[/stdlib/java/lang/annotation/Target.class]]
runtime.js:414 [loading RegularFileObject[/stdlib/java/lang/annotation/ElementType.class]]
runtime.js:414 [loading RegularFileObject[/stdlib/org/teavm/interop/Superclass.class]]
runtime.js:414 [loading RegularFileObject[/stdlib/org/teavm/interop/Rename.class]]
runtime.js:414 [loading RegularFileObject[/stdlib/org/teavm/interop/DelegateTo.class]]
runtime.js:414 [loading RegularFileObject[/stdlib/java/lang/annotation/Annotation.class]]
classes.js:38 Uncaught RangeError: Maximum call stack size exceeded
    at Erk (classes.js:12054)
    at SCk (classes.js:10783)
    at T5d (classes.js:10818)
    at T5d (classes.js:10818)
    at T5d (classes.js:10818)
    at T5d (classes.js:10818)
    at T5d (classes.js:10818)
    at T5d (classes.js:10818)
    at T5d (classes.js:10818)
    at T5d (classes.js:10818)

double to string

Compiling the following code

public class Main {
  public static void main(String[] args){
    System.out.println(1.0);
  }	
}

produces the following error with the latest master

ERROR at Main.java:4 Native method java.lang.Double.doubleToLongBits(D)J has no implementation
    at java.lang.Double.doubleToLongBits
    at org.teavm.classlib.impl.text.DoubleAnalyzer.analyze(DoubleAnalyzer.java:76)
    at java.lang.AbstractStringBuilder.insert(TAbstractStringBuilder.java:351)
    at java.lang.AbstractStringBuilder.append(TAbstractStringBuilder.java:309)
    at java.lang.StringBuilder.append(TStringBuilder.java:61)
    at java.io.PrintStream.println(TPrintStream.java:197)

Supporting latest TeaVM

I've tried building this with newer versions of TeaVM (0.6.1, or 0.7.0-SNAPSHOT), and I get compile errors.

Here is the output when running mvn package after changing teavm version to 0.6.1

This is after checking out and installing the teavm 0.6.1 branch locally.

Problem with String.split

Compiling the following code

public class Main {
  public static void main(String[] args){
    "Hello World".split(" ");        
  }
}

generates this error

ERROR at Main.java:4 Native method java.lang.Character.obtainDigitMapping$$create()Lorg/teavm/platform/metadata/StringResource; has no implementation
    at java.lang.Character.obtainDigitMapping$$create
    at java.lang.Character.obtainDigitMapping
    at java.lang.Character.getDigitMapping(TCharacter.java:315)
    at java.lang.Character.getNumericValue(TCharacter.java:281)
    at java.lang.Character.digit(TCharacter.java:272)
    at java.lang.Character.digit(TCharacter.java:265)
    at java.util.regex.Lexer.readOctals(TLexer.java:867)
    at java.util.regex.Lexer.movePointer(TLexer.java:465)
    at java.util.regex.Lexer.<init>(TLexer.java:230)
    at java.util.regex.Pattern.compileImpl(TPattern.java:335)
    at java.util.regex.Pattern.compile(TPattern.java:321)
    at java.util.regex.Pattern.compile(TPattern.java:1273)
    at java.lang.String.split(TString.java:648)

BuildTimeResourceProxy emits wrong js-code

Hi.

A while back you pointed me to this very cool javac repo of yours. I have been playing around with it for some time and successfully extended some of its functionality for my usecase. I also started to upgrade the repo to the latest jdk and teaVM version. Building my fork(https://github.com/frankbauer/teavm-javac/tree/custom-fielname) seems to work without any error messages using mvn package.

However, when I try the example, the following error is reported:

ReferenceError: Can't find variable: T$p

If I read the code correctly, this error is created in the classes.js file in the following code:
"BuildTimeResourceProxy",117,B,[T$p],0,0,0,0,Z$h,"BuildTimeResourceProxyFactory"

I assume that this Type is the class that BuildTimeResourceProxy inherits from (java.lang.reflect.InvocationHandler).

Since I am still very new to TeaVM I do not know what part of the build process (generating the classlib.txt or calling the TeaVM compiler that creates the classes.js) I have to change to make this a known type. Could you maybe point me in the right direct?

Cannot compile class with non-default constructor

If a class contains a non-default constructor, then the compiler fails with error: java.lang.AssertionError: Value of x -1. Here is the sample code that gives error:

class Main {
    Main(int i) {
    }

    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.