Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
3 changes: 0 additions & 3 deletions sources/net.sf.j2s.core/dist/swingjs/_j2sclasslist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,10 @@ swingjs/api/js/HTML5CanvasContext2D.js
swingjs/api/js/JSInterface.js
swingjs/api/JSMinimalAbstractDocument.js
swingjs/jquery/JQueryUI.js
swingjs/JSAbstractDocument.js
swingjs/JSApp.js
swingjs/JSApplet.js
swingjs/JSAppletThread.js
swingjs/JSAppletViewer.js
swingjs/JSDocumentEvent.js
swingjs/JSFocusPeer.js
swingjs/JSFontMetrics.js
swingjs/JSFrameViewer.js
Expand All @@ -345,7 +343,6 @@ swingjs/JSGraphicsConfiguration.js
swingjs/JSGraphicsEnvironment.js
swingjs/JSMouse.js
swingjs/JSNullComponentPeer.js
swingjs/JSPlainDocument.js
swingjs/JSScreenDevice.js
swingjs/JSThreadGroup.js
swingjs/JSToolkit.js
Expand Down
Binary file modified sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20190425142129
20190516132838
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/SwingJS-site.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,10 @@ swingjs/api/js/HTML5CanvasContext2D.js
swingjs/api/js/JSInterface.js
swingjs/api/JSMinimalAbstractDocument.js
swingjs/jquery/JQueryUI.js
swingjs/JSAbstractDocument.js
swingjs/JSApp.js
swingjs/JSApplet.js
swingjs/JSAppletThread.js
swingjs/JSAppletViewer.js
swingjs/JSDocumentEvent.js
swingjs/JSFocusPeer.js
swingjs/JSFontMetrics.js
swingjs/JSFrameViewer.js
Expand All @@ -345,7 +343,6 @@ swingjs/JSGraphicsConfiguration.js
swingjs/JSGraphicsEnvironment.js
swingjs/JSMouse.js
swingjs/JSNullComponentPeer.js
swingjs/JSPlainDocument.js
swingjs/JSScreenDevice.js
swingjs/JSThreadGroup.js
swingjs/JSToolkit.js
Expand Down
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/net.sf.j2s.core.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20190425142129
20190516132838
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Notes
=====

update 12/4/2019 -- 3.2.4.07
update 12/4/2018 -- 3.2.4.07

this update advances JTextArea, JTextPane, and JEditorPane, and adds many more classes of java.nio.

Expand Down
82 changes: 42 additions & 40 deletions sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Stack;
import java.util.regex.Pattern;

import javax.xml.bind.annotation.XmlElement;

import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.dom.ASTNode;
Expand Down Expand Up @@ -137,6 +134,8 @@
import org.eclipse.jdt.core.dom.WhileStatement;
import org.eclipse.jdt.core.dom.WildcardType;

// BH 2019.05.13 fix for Math.getExponent, ulp, nextDown, nextUp, nextAfter needing qualification
// BH 2019.05.13 fix for Function reference in new Foo()::test(...)
// BH 2019.04.03 fix for @j2sIgnore not including {}
// note to self: It is an annoyance that Eclipse does not recognize an annotation edit
// as a need to recompile automatically
Expand All @@ -148,7 +147,7 @@
* @author Bob Hanson 2017-08,09,10
*
*
*
*
*/
public class Java2ScriptVisitor extends ASTVisitor {

Expand Down Expand Up @@ -528,10 +527,7 @@ public boolean visit(ClassInstanceCreation node) {
private void addConstructor(ITypeBinding javaClass,
// Type type,
IMethodBinding constructorMethodBinding, List<?> arguments, int lambdaArity) {
// String javaClassName = getClassJavaNameForType(type);
String javaClassName = getJavaClassNameQualified(javaClass);
// if (!javaClassName.equals(testName))
// System.out.println("!!! " + javaClassName + " != " + testName);
if ("java.lang.Object".equals(javaClassName)) {
buffer.append(" Clazz.new_()");
return;
Expand Down Expand Up @@ -559,9 +555,17 @@ private void addConstructor(ITypeBinding javaClass,
prefix = ",[";
postfix = "]";
}
if (lambdaArity >= 0)
buffer.append(",[" + this.getLambdaParamList(constructorMethodBinding, lambdaArity) + "]");
else if (!isDefault) {
if (lambdaArity >= 0) {
buffer.append(",[");
String finals = htLocalFinals.get(getNormalizedKey(javaClass));
String params = getLambdaParamList(constructorMethodBinding, lambdaArity);
if (finals != null) {
buffer.append("this,").append(finals);
if (params.length() > 0)
buffer.append(",");
}
buffer.append(params).append("]");
} else if (!isDefault) {
IMethodBinding constructorMethodDeclaration = (constructorMethodBinding == null ? null
: constructorMethodBinding.getMethodDeclaration());
addMethodParameterList(arguments, constructorMethodDeclaration, prefix, postfix, METHOD_CONSTRUCTOR);
Expand Down Expand Up @@ -662,6 +666,7 @@ private void processLocalInstance(ASTNode node, ASTNode anonymousClassDeclaratio

// localName = null;
String finals;

if (isClassTrulyLocal) {
// predefined by class creation step
finals = htLocalFinals.get(getNormalizedKey(binding));
Expand Down Expand Up @@ -733,17 +738,18 @@ private String addInnerDeclaration(ASTNode node, ITypeBinding binding, int lambd
buffer.append(", ");
}
package_methodStackForFinals.pop();

// create the finals list {width: width; height: height} and add all
// newly visited variables to class_visitedVars;
String finals = listFinalVariables(myVisitedVars, lastVisitedVars, currentBlock);

// restore class/package parameters
class_visitedVars = lastVisitedVars;
package_currentBlockForVisit = currentBlock;
class_isAnonymousOrLocal = wasAnonymous;
return finals;
}

static int test = 0;


/**
* Generated final variable list for anonymous class creation. Update the
Expand Down Expand Up @@ -1236,7 +1242,8 @@ private void addMethodInvocation(SimpleName javaQualifier, List<?> arguments, IM
// in using "t.apply" is that t must be non-null.
// if this does not work, then we can go to ($class$.prototype || t)
//
boolean classIsTarget = ((isStatic || isVariableBinding(expression))
boolean classIsTarget = ((isStatic || isVariableBinding(expression)
|| expression instanceof ClassInstanceCreation) // BH Added 2019.05.13
&& lambdaArity == mBinding.getParameterTypes().length);
buffer.append((classIsTarget ? "$class$." : "t.") + finalMethodNameWith$Params + ".apply("
+ (isStatic ? "null" : classIsTarget ? "$class$" : "t") + ",[");
Expand Down Expand Up @@ -2322,6 +2329,8 @@ private void addInnerTypeInstance(ASTNode node, ITypeBinding superAnonOrInnerCla
// add constructor application arguments: [object, parameters]

buffer.append(", [");


if (outerClassExpr == null)
buffer.append("this");
else
Expand Down Expand Up @@ -5408,8 +5417,6 @@ private List<Javadoc> getJ2sJavadoc(ASTNode node, int mode) {
NativeDoc.addJ2sJavadocs(buffer, docs, false);
} else {
docs = package_mapBlockJavadoc.get(Integer.valueOf(node.getStartPosition()));
//?? buffer.append("\n/** looking for " + node + " " + Integer.valueOf(node.getStartPosition())
//?? + " " + (docs != null) + " " + node.getClass().getName() + "*/\n");
}
return docs;
}
Expand Down Expand Up @@ -6074,12 +6081,13 @@ static String checkClassReplacement(String className) {
private final static String defaultNonQualified
// Math and Date both are minor extensions
// of JavaScript, so they are not qualified
= "java.lang.Math;"
= //"java.lang.Math;" +
// MAYBE NOT! + "java.util.Date;"
// swingjs.api.js and javajs.api.js contain
// interfaces to JavaScript methods and so
// are not parameterized.
+ "*.api.js;"

"*.api.js;"
// netscape.JSObject interface includes 8 methods
// that do not need to be parameterized.
// + "netscape.*;"
Expand Down Expand Up @@ -6130,6 +6138,18 @@ private static boolean isPackageOrClassNonqualified(String className) {
* @param methodName not used but could be
*/
static boolean isMethodNonqualified(String className, String methodName) {
if (className.equals("java.lang.Math")) {
switch (methodName) {
case "ulp":
case "nextDown":
case "nextUp":
case "nextAfter":
case "getExponent":
return false;
default:
return true;
}
}
return (isPackageOrClassNonqualified(className));
}

Expand Down Expand Up @@ -6276,9 +6296,6 @@ static class ClassAnnotation {
private String qName;

protected ClassAnnotation(String qName, Annotation annotation, ASTNode node) {
// System.out.println(">>>>" + qName + " "
// + annotation.getClass().getName()
// + " " + annotation);
this.qName = qName;
this.annotation = annotation;
this.node = node;
Expand All @@ -6297,8 +6314,6 @@ public static void addClassAnnotations(int accessType, List<ClassAnnotation> cla
for (int i = 0; i < class_annotations.size(); i++) {
ClassAnnotation a = class_annotations.get(i);
String str = a.annotation.toString();
// System.out.println(">>>str " + str);
// System.out.println(">>>ann " + a.annotation.getClass().getName());
if (a.annotation instanceof NormalAnnotation) {
// @XmlElement(name="test",type=Integer.class)
// remove commas, add quotes
Expand All @@ -6312,7 +6327,6 @@ public static void addClassAnnotations(int accessType, List<ClassAnnotation> cla
// add quotes
List<ASTNode> expressions = null;
Expression e = ((SingleMemberAnnotation) a.annotation).getValue();
// System.out.println(">>>e " + e.getClass().getName());
if (e instanceof TypeLiteral) {
expressions = new ArrayList<ASTNode>();
expressions.add(e);
Expand Down Expand Up @@ -6400,8 +6414,6 @@ public static void addClassAnnotations(int accessType, List<ClassAnnotation> cla
}

private static String annotationNameValue(String name, Object value) {
// System.out.println(">>>value " + value + " " + value.getClass().getName() + "
// = " + value.toString());
String str = (name == null ? "" : name + "=");
if (value instanceof TypeLiteral) {
str += "\"" + ((TypeLiteral) value).getType().resolveBinding().getQualifiedName() + ".class\"";
Expand Down Expand Up @@ -6733,17 +6745,6 @@ public static void dumpStack(String msg) {
*/
public boolean visit(CreationReference node) {
// // lambda_C
// buffer.append("Clazz.newLambda(function(t){return ");
// Type classType = node.getType();
// ITypeBinding tbinding = classType.resolveBinding();
// if (classType instanceof ArrayType) {
// addArrayConstructor(tbinding, null);
// } else {
// IMethodBinding mBinding = node.resolveMethodBinding();
// addConstructor(classType, mBinding, null);
// }
// buffer.append("},0,'S')");
// was:
ITypeBinding binding = node.resolveTypeBinding();
processLocalInstance(node, null, binding, null, null, LAMBDA_CREATION, false);
return false;
Expand Down Expand Up @@ -6898,6 +6899,8 @@ private char getLambdaType(ITypeBinding binding) {
}

private void addLambdaBody(ASTNode body) {


if (body instanceof Block) {
body.accept(this);
} else {
Expand Down Expand Up @@ -6938,18 +6941,17 @@ private void addLambdaMethod(ASTNode lnode, IMethodBinding mBinding) {
return;
}
if (lnode instanceof CreationReference) {
// int[]::new;
buffer.append("/*lambda_C*/");
processMethodDeclaration(mBinding, null, null, false, LAMBDA_CREATION);
CreationReference node = (CreationReference) lnode;
Type ctype = node.getType();
ITypeBinding binding = ctype.resolveBinding();
if (ctype instanceof ArrayType) {
// int[]::new;
addArrayConstructor(binding, null);
} else {
addConstructor(binding,
// ctype,
mBinding, null, mBinding.getParameterTypes().length);
// MatchSink::new;
addConstructor(binding, mBinding, null, mBinding.getParameterTypes().length);
}
buffer.append("});\r\n");
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
eclipse.preferences.version=1
encoding//src/test/Test_Char.java=UTF-8
encoding/<project>=UTF-8
3 changes: 0 additions & 3 deletions sources/net.sf.j2s.java.core/_j2sclasslist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,10 @@ swingjs/api/js/HTML5CanvasContext2D.js
swingjs/api/js/JSInterface.js
swingjs/api/JSMinimalAbstractDocument.js
swingjs/jquery/JQueryUI.js
swingjs/JSAbstractDocument.js
swingjs/JSApp.js
swingjs/JSApplet.js
swingjs/JSAppletThread.js
swingjs/JSAppletViewer.js
swingjs/JSDocumentEvent.js
swingjs/JSFocusPeer.js
swingjs/JSFontMetrics.js
swingjs/JSFrameViewer.js
Expand All @@ -345,7 +343,6 @@ swingjs/JSGraphicsConfiguration.js
swingjs/JSGraphicsEnvironment.js
swingjs/JSMouse.js
swingjs/JSNullComponentPeer.js
swingjs/JSPlainDocument.js
swingjs/JSScreenDevice.js
swingjs/JSThreadGroup.js
swingjs/JSToolkit.js
Expand Down
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
3 changes: 0 additions & 3 deletions sources/net.sf.j2s.java.core/dist/_j2sclasslist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,10 @@ swingjs/api/js/HTML5CanvasContext2D.js
swingjs/api/js/JSInterface.js
swingjs/api/JSMinimalAbstractDocument.js
swingjs/jquery/JQueryUI.js
swingjs/JSAbstractDocument.js
swingjs/JSApp.js
swingjs/JSApplet.js
swingjs/JSAppletThread.js
swingjs/JSAppletViewer.js
swingjs/JSDocumentEvent.js
swingjs/JSFocusPeer.js
swingjs/JSFontMetrics.js
swingjs/JSFrameViewer.js
Expand All @@ -345,7 +343,6 @@ swingjs/JSGraphicsConfiguration.js
swingjs/JSGraphicsEnvironment.js
swingjs/JSMouse.js
swingjs/JSNullComponentPeer.js
swingjs/JSPlainDocument.js
swingjs/JSScreenDevice.js
swingjs/JSThreadGroup.js
swingjs/JSToolkit.js
Expand Down
Loading