BobHanson / java2script

Java2Script provides an Eclipse Java to JavaScript transpiler, with a nearly complete implementation of the Java Virtual Machine with AWT and Swing in JavaScript, with simple, automated parallel creation of both class files and js files. To date, over 600 applets have been converted.
https://chemapps.stolaf.edu/swingjs/examples.htm
Other
24 stars 11 forks source link

@j2sNative may not work depending on its position in an expression #241

Closed warownia1 closed 8 months ago

warownia1 commented 2 years ago

@j2sNative, when used in an expression, may not appear in the transpiled code depending on its position. For example:

boolean var1 = /** @j2sNative true || */ false;

is transpiled to

var var1=true ||false;

but when the order is reversed

boolean var2 = false /** @j2sNative || true */;

then it is transpiled to

var var2=false;

A possibly related problem occurs when @j2sNative is used inside an if statement following an expression

if (false /** @j2sNative || true */) {
}

becomes

if (false) {
|| true
}
BobHanson commented 2 years ago

Yes, you must do that in the first order. Is a bit odd, admittedly.

On Mon, Sep 26, 2022 at 7:28 AM Mateusz Warowny @.***> wrote:

@j2sNative, when used in an expression, may not appear in the transpiled code depending on its position. For example:

boolean var1 = /* @j2sNative true || / false;

is transpiled to

var var1=true ||false;

but when the order is reversed

boolean var2 = false /* @j2sNative || true /;

then it is transpiled to

var var2=false;

A possibly related problem occurs when @j2sNative is used inside an if statement following an expression

if (false /* @j2sNative || true /) { }

becomes

if (false) {|| true}

— Reply to this email directly, view it on GitHub https://github.com/BobHanson/java2script/issues/241, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEHNCW4I4ABQQRIF42ZMZGDWAGJITANCNFSM6AAAAAAQVX5JJQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Robert M. Hanson Professor of Chemistry St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr

If nature does not answer first what we want, it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900

We stand on the homelands of the Wahpekute Band of the Dakota Nation. We honor with gratitude the people who have stewarded the land throughout the generations and their ongoing contributions to this region. We acknowledge the ongoing injustices that we have committed against the Dakota Nation, and we wish to interrupt this legacy, beginning with acts of healing and honest storytelling about this place.