Skip to content

Commit 6025e1e

Browse files
authored
Merge pull request #93 from BobHanson/hanson1
Hanson1
2 parents 3836543 + 2ebd271 commit 6025e1e

File tree

513 files changed

+97503
-947
lines changed

Some content is hidden

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

513 files changed

+97503
-947
lines changed
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

12.8 KB
Binary file not shown.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* - Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* - Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
*
15+
* - Neither the name of Oracle or the names of its
16+
* contributors may be used to endorse or promote products derived
17+
* from this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
32+
package components;
33+
34+
/*
35+
* SimpleTableDemo.java requires no other files.
36+
*/
37+
38+
import javax.swing.JFrame;
39+
import javax.swing.JPanel;
40+
import javax.swing.JScrollPane;
41+
import javax.swing.JTable;
42+
import java.awt.Dimension;
43+
import java.awt.GridLayout;
44+
import java.awt.event.MouseAdapter;
45+
import java.awt.event.MouseEvent;
46+
47+
public class SimpleTableDemo extends JPanel {
48+
private boolean DEBUG = false;
49+
50+
public SimpleTableDemo() {
51+
super(new GridLayout(1,0));
52+
53+
String[] columnNames = {"First Name",
54+
"Last Name",
55+
"Sport",
56+
"# of Years",
57+
"Vegetarian"};
58+
59+
Object[][] data = {
60+
{"Kathy", "Smith",
61+
"Snowboarding", new Integer(5), new Boolean(false)},
62+
{"John", "Doe",
63+
"Rowing", new Integer(3), new Boolean(true)},
64+
{"Sue", "Black",
65+
"Knitting", new Integer(2), new Boolean(false)},
66+
{"Jane", "White",
67+
"Speed reading", new Integer(20), new Boolean(true)},
68+
{"Joe", "Brown",
69+
"Pool", new Integer(10), new Boolean(false)}
70+
};
71+
72+
final JTable table = new JTable(data, columnNames);
73+
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
74+
table.setFillsViewportHeight(true);
75+
76+
if (DEBUG) {
77+
table.addMouseListener(new MouseAdapter() {
78+
public void mouseClicked(MouseEvent e) {
79+
printDebugData(table);
80+
}
81+
});
82+
}
83+
84+
//Create the scroll pane and add the table to it.
85+
JScrollPane scrollPane = new JScrollPane(table);
86+
87+
//Add the scroll pane to this panel.
88+
add(scrollPane);
89+
}
90+
91+
private void printDebugData(JTable table) {
92+
int numRows = table.getRowCount();
93+
int numCols = table.getColumnCount();
94+
javax.swing.table.TableModel model = table.getModel();
95+
96+
System.out.println("Value of data: ");
97+
for (int i=0; i < numRows; i++) {
98+
System.out.print(" row " + i + ":");
99+
for (int j=0; j < numCols; j++) {
100+
System.out.print(" " + model.getValueAt(i, j));
101+
}
102+
System.out.println();
103+
}
104+
System.out.println("--------------------------");
105+
}
106+
107+
/**
108+
* Create the GUI and show it. For thread safety,
109+
* this method should be invoked from the
110+
* event-dispatching thread.
111+
*/
112+
private static void createAndShowGUI() {
113+
//Create and set up the window.
114+
JFrame frame = new JFrame("SimpleTableDemo");
115+
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
116+
117+
//Create and set up the content pane.
118+
SimpleTableDemo newContentPane = new SimpleTableDemo();
119+
newContentPane.setOpaque(true); //content panes must be opaque
120+
frame.setContentPane(newContentPane);
121+
122+
//Display the window.
123+
frame.pack();
124+
frame.setVisible(true);
125+
}
126+
127+
public static void main(String[] args) {
128+
//Schedule a job for the event-dispatching thread:
129+
//creating and showing this application's GUI.
130+
javax.swing.SwingUtilities.invokeLater(new Runnable() {
131+
public void run() {
132+
createAndShowGUI();
133+
}
134+
});
135+
}
136+
}

0 commit comments

Comments
 (0)