Skip to content

Commit 946bf83

Browse files
authored
Merge pull request #74 from java2script/master
graphics, license update
2 parents 3a572c7 + 6025e1e commit 946bf83

File tree

515 files changed

+97867
-1121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

515 files changed

+97867
-1121
lines changed

LICENSE.txt

Lines changed: 357 additions & 173 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ automated production of browser-ready JavaScript versions of Java applications a
2525

2626
# QuickStart
2727

28-
See https://github.com/BobHanson/java2script/tree/master/dist and the README file in that directory.
28+
See https://github.com/BobHanson/java2script/tree/master/sources/net.sf.j2s.core/dist and the README file in that directory.
2929

3030
# History - 2017-
3131

12.8 KB
Binary file not shown.
-140 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181204022550
1+
20181213165944
12.8 KB
Binary file not shown.
-140 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181204022550
1+
20181213165944

sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,62 @@ public class CorePlugin extends Plugin {
1919
* register the bundle version properly. So we use VERSION here instead.
2020
*
2121
*/
22-
public static String VERSION = "3.2.4.04";
22+
public static String VERSION = "3.2.4.05";
23+
// BH 12/13/2018 -- 3.2.4.05 fixes problem with OuterClass.this.foo() not using .apply()
2324
// BH 11/10/2018 -- 3.2.4.04 additional support for JAXB
24-
// BH 11/04/2018 -- 3.2.4.02 support for JAXB - all accessor types, ObjectFactory, package-level namespace, but not yet accessor type
25+
// BH 11/4/2018 -- 3.2.4.02 broad JAXB support
2526
// BH 10/27/2018 -- 3.2.4.01 support for JAXB FIELD+propOrder and NONE types
2627
// BH 9/28/2018 -- 3.2.4.00 adds minimal support for JAXB
27-
// BH 9/23/2018 -- 3.2.3.00 new transpiler + SwingJS-site.zip - support for java.applet.Applet and java.awt.* controls without use of a2s.*
28+
// BH 9/23/2018 -- 3.2.3.00 adds support for java.applet.Applet and java.awt.* controls without use of a2s.*
2829
// BH 9/16/2018 -- 3.2.2.06 removes "$" in JApplet public method alternative name
2930
// 3.2.2.04 2018.08.15 fixing Java->JavaScript "getFinal" code for class names.
3031
// 3.2.2.04 adds support for window-level applets, such as JmolApplet
3132
// 3.2.2.03 adds Java 8 function and stream
3233
// 3.2.2.02 adds $-qualified names for all methods
34+
// BH 8/20/2018 -- fix for return (short)++;
35+
// BH 8/19/2018 -- refactored to simplify $finals$
36+
// BH 8/12/2018 -- refactored to simplify naming issues
37+
// BH 8/6/2018 -- additional Java 8 fixes; enum $valueOf$S to valueOf$S
38+
// BH 8/1/2018 -- adds interface default methods as C$.$defaults$(C$)
39+
// BH 7/29/2018 -- java.util.stream.Collectors is returning java.util.Collectionthis.b$['java.util.Collection'].add
40+
// BH 7/25/2018 -- allows for direct private function calls in inner and anonymous classes using var p$, p$$, p$$$, etc
41+
// BH 7/22/2018 -- fixes improper use of charCodeAt() to replace charCode().$c() when not java.lang.String.charAt
42+
// BH 7/20/2018 -- removes qualifications for single-abstract method overrides
43+
// BH 7/19/2018 -- fixes Enum.Enum
44+
// BH 7/18/2018 -- addw Java 8 try without catch or finally
45+
// BH 7/16/2018 -- adds Java 8 :: operator
46+
// BH 7/15/2018 -- adds Java 8 lambda expressions
47+
// BH 7/14/2018 -- removes java2scriptbuilder; uses CompilationParticipant instead
48+
// BH 7/5/2018 -- fixes int | char
49+
// BH 7/3/2018 -- adds tryWithResource
50+
// BH 7/3/2018 -- adds effectively final -- FINAL keyword no longer necessary
51+
// BH 6/27/2018 -- fix for a[Integer] not becoming a[Integer.valueOf]
52+
// BH 6/26/2018 -- method logging via j2s.log.methods.called and j2s.log.methods.declared
53+
// BH 6/24/2018 -- synchronized(a = new Object()) {...} ---> ...; only if an assignment or not a simple function call to Object.getTreeLock()
54+
// BH 6/23/2018 -- synchronized(a = new Object()) {...} ---> if(!(a = new Object()) {throw new NullPointerException()}else{...}
55+
// BH 6/21/2018 -- CharSequence.subSequence() should be defined both subSequence$I$I and subSequence
56+
// BH 6/20/2018 -- fixes for (int var : new int[] {3,4,5}) becoming for var var
57+
// BH 6/19/2018 -- adds .j2s j2s.class.replacements=org.apache.log4j.->jalview.javascript.log4j.;
58+
// BH 5/15/2018 -- fix for a[pt++] |= 3 incrementing pt twice and disregarding a[][] (see test/Test_Or.java)
59+
// BH 3/27/2018 -- fix for anonymous inner classes of inner classes not having this.this$0
60+
// BH 1/5/2018 -- @j2sKeep removed; refactored into one class
61+
// BH 12/31/2017 -- competely rewritten for no run-time ambiguities
62+
// BH 9/10/2017 -- adds full byte, short, and int distinction using class-level local fields $b$, $s$, and $i$, which are IntXArray[1]. (See ASTKeywordVisitor)
63+
// BH 9/7/2017 -- primitive casting for *=,/=,+=,-=,&=,|=,^=
64+
// BH 9/7/2017 -- primitive numeric casting -- (byte) was ignored so that (byte) 0xFF remained 0xFF.
65+
// BH 9/7/2017 -- fixed multiple issues with char and Character
66+
// BH 9/4/2017 -- java.awt, javax.swing, swingjs code added; additional fixes required
67+
// BH 8/30/2017 -- all i/o working, including printf and FileOutputStream
68+
// BH 8/19/2017 -- String must implement CharSequence, so all .length() -> .length$()
69+
// BH 8/19/2017 -- varargs logic fixed for missing argument
70+
// BH 8/18/2017 -- array instanceof, reflection, componentType fixes
71+
// BH 8/16/2017 -- JSE8-UnionType catch (Exception... | Exception...) {...}
72+
// BH 8/13/2017 -- includes native code calls in System.err
73+
// BH 7/31/2017 -- extensively reworked for fully qualified method names and no SAEM
3374
// 3.2.1.01 original SwingJS version through 2017 adds $-signatures for methods
3475
// 3.1.1 last Zhou Renjian unqualified name version
76+
77+
3578
/**
3679
* The constructor.
3780
*/

sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java

Lines changed: 28 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -139,54 +139,6 @@
139139
// as a need to recompile automatically
140140
// TODO: Create a j2s configuration tag "j2s.jaxb.packages= package;package;package..."
141141
// that will direct the transpiler to create __ANN__ in any class within this package.
142-
// BH 11/4/2018 -- 3.2.4.02 broad JAXB support
143-
// BH 10/27/2018 -- 3.2.4.01 support for JAXB FIELD+propOrder and NONE types
144-
// BH 9/28/2018 -- 3.2.4.00 adds minimal support for JAXB
145-
// BH 9/23/2018 -- 3.2.3.00 adds support for java.applet.Applet and java.awt.* controls without use of a2s.*
146-
// BH 9/16/2018 -- 3.2.2.06 removes "$" in JApplet public method alternative name
147-
// BH 8/20/2018 -- fix for return (short)++;
148-
// BH 8/19/2018 -- refactored to simplify $finals$
149-
// BH 8/12/2018 -- refactored to simplify naming issues
150-
// BH 8/6/2018 -- additional Java 8 fixes; enum $valueOf$S to valueOf$S
151-
// BH 8/1/2018 -- adds interface default methods as C$.$defaults$(C$)
152-
// BH 7/29/2018 -- java.util.stream.Collectors is returning java.util.Collectionthis.b$['java.util.Collection'].add
153-
154-
// BH 7/25/2018 -- allows for direct private function calls in inner and anonymous classes using var p$, p$$, p$$$, etc
155-
// BH 7/22/2018 -- fixes improper use of charCodeAt() to replace charCode().$c() when not java.lang.String.charAt
156-
// BH 7/20/2018 -- removes qualifications for single-abstract method overrides
157-
// BH 7/19/2018 -- fixes Enum.Enum
158-
// BH 7/18/2018 -- addw Java 8 try without catch or finally
159-
// BH 7/16/2018 -- adds Java 8 :: operator
160-
// BH 7/15/2018 -- adds Java 8 lambda expressions
161-
// BH 7/14/2018 -- removes java2scriptbuilder; uses CompilationParticipant instead
162-
// BH 7/5/2018 -- fixes int | char
163-
// BH 7/3/2018 -- adds tryWithResource
164-
// BH 7/3/2018 -- adds effectively final -- FINAL keyword no longer necessary
165-
// BH 6/27/2018 -- fix for a[Integer] not becoming a[Integer.valueOf]
166-
// BH 6/26/2018 -- method logging via j2s.log.methods.called and j2s.log.methods.declared
167-
// BH 6/24/2018 -- synchronized(a = new Object()) {...} ---> ...; only if an assignment or not a simple function call to Object.getTreeLock()
168-
// BH 6/23/2018 -- synchronized(a = new Object()) {...} ---> if(!(a = new Object()) {throw new NullPointerException()}else{...}
169-
// BH 6/21/2018 -- CharSequence.subSequence() should be defined both subSequence$I$I and subSequence
170-
// BH 6/20/2018 -- fixes for (int var : new int[] {3,4,5}) becoming for var var
171-
// BH 6/19/2018 -- adds .j2s j2s.class.replacements=org.apache.log4j.->jalview.javascript.log4j.;
172-
// BH 5/15/2018 -- fix for a[pt++] |= 3 incrementing pt twice and disregarding a[][] (see test/Test_Or.java)
173-
// BH 3/27/2018 -- fix for anonymous inner classes of inner classes not having this.this$0
174-
// BH 1/5/2018 -- @j2sKeep removed; refactored into one class
175-
176-
// BH 12/31/2017 -- competely rewritten for no run-time ambiguities
177-
// BH 9/10/2017 -- adds full byte, short, and int distinction using class-level local fields $b$, $s$, and $i$, which are IntXArray[1]. (See ASTKeywordVisitor)
178-
// BH 9/7/2017 -- primitive casting for *=,/=,+=,-=,&=,|=,^=
179-
// BH 9/7/2017 -- primitive numeric casting -- (byte) was ignored so that (byte) 0xFF remained 0xFF.
180-
// BH 9/7/2017 -- fixed multiple issues with char and Character
181-
// BH 9/4/2017 -- java.awt, javax.swing, swingjs code added; additional fixes required
182-
// BH 8/30/2017 -- all i/o working, including printf and FileOutputStream
183-
// BH 8/19/2017 -- String must implement CharSequence, so all .length() -> .length$()
184-
// BH 8/19/2017 -- varargs logic fixed for missing argument
185-
// BH 8/18/2017 -- array instanceof, reflection, componentType fixes
186-
// BH 8/16/2017 -- JSE8-UnionType catch (Exception... | Exception...) {...}
187-
// BH 8/13/2017 -- includes native code calls in System.err
188-
// BH 7/31/2017 -- extensively reworked for fully qualified method names and no SAEM
189-
190142
/**
191143
*
192144
* @author zhou renjian 2006-12-3
@@ -640,10 +592,6 @@ private String getClassJavaNameForType(Type type) {
640592
QualifiedType qualType = (QualifiedType) type;
641593
return getClassJavaNameForType(qualType.getQualifier()) + "." + qualType.getName().getIdentifier();
642594
}
643-
// if (type instanceof NameQualifiedType) {
644-
// NameQualifiedType nType = (NameQualifiedType) type;
645-
// return getClassJavaNameForClass(nType.getQualifier()) + "." + nType.getName().getIdentifier();
646-
// }
647595
if (type instanceof ArrayType)
648596
return getClassJavaNameForType(((ArrayType) type).getElementType());
649597
if (type instanceof ParameterizedType)
@@ -1174,30 +1122,19 @@ private void addMethodInvocation(SimpleName javaQualifier, List<?> arguments, IM
11741122
ITypeBinding declaringClass = mBinding.getDeclaringClass();
11751123
String declaringClassJavaClassName = getJavaClassNameQualified(declaringClass);
11761124

1177-
// System. out.println -- System.out is static, but println is not.
1178-
// nonetheless, Modifier.isStatic() returns true.
1179-
1180-
boolean isStatic = isStatic(mBinding);// || expression != null && isStatic(expression.resolveTypeBinding()));
1181-
// if (!isStatic && expression instanceof Name) {
1182-
// IBinding binding = ((Name) expression).resolveBinding();
1183-
// // no, because sometimes these are not fully qualified className =
1184-
// // expression.toString();
1185-
// // because System.out is the name of a static field, not a class
1186-
// isStatic |= isStatic(binding);
1187-
// }
1125+
boolean isStatic = isStatic(mBinding);
11881126
boolean isPrivate = isPrivate(mBinding);
11891127
boolean isPrivateAndNotStatic = isPrivate && !isStatic;
11901128
String privateVar = (isPrivateAndNotStatic ? getPrivateVar(declaringClass, false) : null);
11911129
boolean doLog = (!isPrivate && global_htMethodsCalled != null);
1192-
1193-
boolean needBname = (!isStatic && expression == null && lambdaArity < 0
1194-
&& !areEqual(declaringClass, class_typeBinding)
1195-
&& !class_typeBinding.isAssignmentCompatible(declaringClass));
1196-
1130+
boolean needBname = (!isStatic && lambdaArity < 0 &&
1131+
(expression == null
1132+
? !areEqual(declaringClass, class_typeBinding)
1133+
&& !class_typeBinding.isAssignmentCompatible(declaringClass)
1134+
: expression instanceof ThisExpression && ((ThisExpression) expression).getQualifier() != null)
1135+
);
11971136
String bname = (needBname ? getThisRefOrSyntheticReference(javaQualifier, declaringClass, null) : null);
1198-
11991137
// add the qualifier
1200-
12011138
int pt = buffer.length();
12021139
if (isPrivateAndNotStatic) {
12031140
// note that the following expression will not work if the method is private:
@@ -1209,22 +1146,20 @@ private void addMethodInvocation(SimpleName javaQualifier, List<?> arguments, IM
12091146
doLog = false;
12101147
if (bname != null)
12111148
allowClazzNewLambda = false;
1212-
} else {
1213-
if (expression == null) {
1214-
doLog = false;
1215-
if (bname != null) {
1216-
buffer.append(bname);
1217-
buffer.append(".");
1218-
} else if (!isStatic) {
1219-
buffer.append("this.");
1220-
} else {
1221-
// this will be C$., I think.
1222-
}
1223-
} else {
1224-
appendFinalMethodQualifier(expression, declaringClassJavaClassName, bname,
1225-
(isStatic && !isPrivate ? FINAL_ESCAPECACHE : FINAL_CACHE));
1149+
} else if (expression == null) {
1150+
doLog = false;
1151+
if (bname != null) {
1152+
buffer.append(bname);
12261153
buffer.append(".");
1154+
} else if (!isStatic) {
1155+
buffer.append("this.");
1156+
} else {
1157+
// this will be C$., I think.
12271158
}
1159+
} else {
1160+
appendFinalMethodQualifier(expression, declaringClassJavaClassName, bname,
1161+
(isStatic && !isPrivate ? FINAL_ESCAPECACHE : FINAL_CACHE));
1162+
buffer.append(".");
12281163
}
12291164
// keep a pointer, because we may rewrite this
12301165
int ptLog = (doLog ? buffer.length() : 0);
@@ -1247,8 +1182,7 @@ private void addMethodInvocation(SimpleName javaQualifier, List<?> arguments, IM
12471182
&& (methodName.equals("indexOf") || methodName.equals("lastIndexOf"))) {
12481183
// indicate to boxer method to use method "q" not "p" here.
12491184
// This allows characters to be left as strings in String.indexOf$I and
1250-
// String.lastIndexOf$I
1251-
// for faster processing.
1185+
// String.lastIndexOf$I for faster processing.
12521186
isIndexOf = true;
12531187
}
12541188
}
@@ -1344,6 +1278,7 @@ private void appendFinalMethodQualifier(Expression qualifier, String declaringCl
13441278
} else {
13451279
// xxxx.field.foo()
13461280
// (x ? y : z).foo()
1281+
// xxx.this.foo()
13471282
qualifier.accept(this);
13481283
}
13491284
}
@@ -3431,8 +3366,13 @@ public boolean visit(SuperFieldAccess node) {
34313366
*
34323367
*/
34333368
public boolean visit(ThisExpression node) {
3434-
buffer.append(node.getQualifier() == null ? "this"
3435-
: getThisRefOrSyntheticReference(node, node.resolveTypeBinding(), "this"));
3369+
if (node.getQualifier() == null) {
3370+
buffer.append("this");
3371+
return false;
3372+
}
3373+
// xxxx.this.x
3374+
// xxxx.this.foo()
3375+
buffer.append(getThisRefOrSyntheticReference(node, node.resolveTypeBinding(), "this"));
34363376
return false;
34373377
}
34383378

0 commit comments

Comments
 (0)