dragome / dragome-sdk

Dragome is a tool for creating client side web applications in pure Java (JVM) language.
http://www.dragome.com
Other
80 stars 20 forks source link

Critical bug. #109

Closed xpenatan closed 8 years ago

xpenatan commented 8 years ago

The code below fails to generate.

public class MyTest {

    public MyTest() {

        System.out.println("PASS  1111");

        try {
            boolean flag = true;
            Object obj1 = null;
            Object obj2 = null;
            while (flag) {
                if (obj1 == null)
                {
                    boolean mybool = false;
                }
                else if(obj2 == null)
                {
                    boolean test = false;
                }
            }
        } catch (Exception ex) {

        }

        System.out.println("PASS  2222");
    }
}

It generates a empty constructor. Its something wrong with try catch and checking null

xpenatan commented 8 years ago

There is also this error that dragome adding to the generated source in some classes:

ERROR("dex:aput-short"); ERROR("dex:shl-int-lit8"); ERROR("dex:sget-char"); ERROR("dex:shr-long-2addr"); ERROR("dex:and-long-2addr"); ERROR("dex:aget-short"); ERROR("dex:ushr-long");

there are 30 of them. What it means?

Some are in gdx json reader, gdx XmlReader$Element, JarClasspathEntry, java_util_Timer. And they are preventing from running libgdx correctly like scene2d (user interface) which use json class.

fpetrola commented 8 years ago

These errors are related to XMLVM compiler phase, when first compiler (j2js) is not able to compile a class method (mainly when it is not standard java bytecode) this second compiler is performing an exactly transcription from bytecode to js (xmlvm). These dex:xxxx errors means that xmlvm found some bytecodes that are not implemented yet. Most of these bytecodes are implemented in newer xmlvm versions so we can fix it by copying these transcriptions from xmlvm master branch. Do you have a list of absent bytecodes?

xpenatan commented 8 years ago

How do I get this list of bytecodes? There are classes that have like 5 errors in same method. I will try to reproduce it in shorter class when I get home.

dobesv commented 8 years ago

I guess he's looking for the full list of unique ERROR lines you are seeing.

On Wed, Jun 29, 2016 at 9:49 AM Xpe notifications@github.com wrote:

How do I get this list of bytecodes? There are classes that have like 5 errors in same method. I will try to reproduce it in shorter class when I get home.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dragome/dragome-sdk/issues/109#issuecomment-229417400, or mute the thread https://github.com/notifications/unsubscribe/AAUAmWX-D0LVDGu9ivBZVbG21JZ4Nljpks5qQqIAgaJpZM4JAlN2 .

fpetrola commented 8 years ago

xmlvm transforms jvm bytecode to delvik bytecode, and these absent bytecodes can be easily implemented by adding them to the list of similar already implemented bytecodes, for example dex:aput-short and dex:aget-short:

<xsl:template match="dex:aput|dex:aput-wide|dex:aput-boolean|dex:aput-char|dex:aput-object">
  <xsl:text>
            __r</xsl:text>
  <xsl:value-of select="@vy" />
  <xsl:text>[__r</xsl:text>
  <xsl:value-of select="@vz" />
  <xsl:text>] = __r</xsl:text>
  <xsl:value-of select="@vx" />
  <xsl:text>;</xsl:text>
</xsl:template>
xpenatan commented 8 years ago

@fpetrola adding that seems to fix case 154. I tried to fix case 180 but the code below seems wrong.

<xsl:template match="dex:shl-int-lit8">
  <xsl:text>
           __r</xsl:text>
  <xsl:value-of select="@vx"/>
  <xsl:text> = __r</xsl:text>
  <xsl:value-of select="@vy"/>
  <xsl:text> &gt;&gt; </xsl:text>
  <xsl:value-of select="@value"/>
  <xsl:text>;</xsl:text>
</xsl:template>

Its shifting and overriding the array.

image

Since I have no idea what it does cant do much.

I guess is better for you to download the json classes and see whats wrong.

-- EDIT, managed to understand that it should be '&lt'. but well, still more errors, this time is at https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/utils/Json.java#L1006 with "Unable to convert value to required type: file: default.fnt (java.lang.String)". maybe a method is not implemented. going to do more checking.

-- EDIT 2: Found out that https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/utils/Json.java#L986 " type == String.class " is failing to compare. Debugging in java it should go in because its a String but it does not in javascript. (trying to reproduce)

xpenatan commented 8 years ago

Third bug so far:

bug3

It should go to case 744 and returns because r17 is a string and r23 and r19 should be equal.

String.class is creating realname with dots and forName is creating with underline. which one should be?

xpenatan commented 8 years ago

Possible to support Field#getType() ? after doing quick fixes to Json to work Now im stuck (https://github.com/dragome/dragome-sdk/blob/ee7da3a95182dcadaab85bb4664180cd6e880a78/dragome-js-jre/src/main/java/java/lang/reflect/Field.java#L128)

fpetrola commented 8 years ago

There are two ways to implement getType: first one is to follow current dragome conventions about members names, using a suffix to declare field type on its name, this approach is the best one but requires more testing than the second one. The second approach is about saving metadata about each field on each existent class querying this metadata inside getType method implementation, this one is more decoupled but adds some overhead in terms of file size and performance. I've created issue #110 to update status.

fpetrola commented 8 years ago

Could you split this issue in several bugs to organize each status isolated?