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
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Java2Script Core
Bundle-SymbolicName: net.sf.j2s.core;singleton:=true
Bundle-Version: 3.2.2
Bundle-Version: 3.2.4
Bundle-Activator: net.sf.j2s.core.CorePlugin
Bundle-Vendor: j2s.sourceforge.net
Require-Bundle: org.eclipse.core.runtime,
Expand Down
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
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 @@
20180926065607
20181001183306
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions sources/net.sf.j2s.core/dist/swingjs/ver/3.2.3/timestamp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20180927214151
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/timestamp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20181001183306
14 changes: 14 additions & 0 deletions sources/net.sf.j2s.core/doc/Differences.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Notes
=====

update 9/29/2018 -- 3.2.4 adds support for JAXB, changes default for ResourceBundle.getBundle
update 9/23/2018 -- 3.2.3 adds support for direct use of java.awt.* components and java.applet.Applet
-- no need for switching to a2s.*
update 7/14/2018 -- 3.2.1 removes Java2ScriptJavaBuilder; uses CompilationParticipant instead
Expand Down Expand Up @@ -303,6 +304,8 @@ LookAndFeel
toString() may need to be explicit
myClass.getField not implemented
"window" and other reserved JavaScript names
ResourceBundle.getBundle


MAJOR ISSUES--for Bob and Udo within SwingJS
============================================
Expand Down Expand Up @@ -548,6 +551,17 @@ No reserved top-level JavaScript name is allowed for a package name. So, for exa
one must rename packages such as "window" or "document" to names such as "win" or "doc".


ResourceBundle.getBundle
------------------------

java.util.ResourceBundle(String) default is Control.FORMAT_DEFAULT, which
first checks for a Java class, then a properties file. This causes problems
as missing class files is a major failure case. The default in SwingJS is
FORMAT_PROPERTIES meaning that the default is NOT to look for a class file.
It is felt that the developer should know which of these it is, and if it is
a class file, then the ResourceBundle call should specify that.


MAJOR ISSUES--for Bob and Udo within SwingJS
============================================

Expand Down
3 changes: 2 additions & 1 deletion sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class CorePlugin extends Plugin {
* register the bundle version properly. So we use VERSION here instead.
*
*/
public static String VERSION = "3.2.3.00";
public static String VERSION = "3.2.4.00";
// BH 9/28/2018 -- 3.2.4.00 adds minimal support for JAXB
// 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.*
// BH 9/16/2018 -- 3.2.2.06 removes "$" in JApplet public method alternative name
// 3.2.2.04 2018.08.15 fixing Java->JavaScript "getFinal" code for class names.
Expand Down
197 changes: 134 additions & 63 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 @@ -132,7 +132,8 @@
import org.eclipse.jdt.core.dom.WhileStatement;
import org.eclipse.jdt.core.dom.WildcardType;

// BH 9/23/2018 -- 3.2.2.07 adds support for java.applet.Applet and java.awt.* controls without use of a2s.*
// BH 9/28/2018 -- 3.2.4.00 adds minimal support for JAXB
// BH 9/23/2018 -- 3.2.3.00 adds support for java.applet.Applet and java.awt.* controls without use of a2s.*
// BH 9/16/2018 -- 3.2.2.06 removes "$" in JApplet public method alternative name
// BH 8/20/2018 -- fix for return (short)++;
// BH 8/19/2018 -- refactored to simplify $finals$
Expand Down Expand Up @@ -258,6 +259,10 @@ public class Java2ScriptVisitor extends ASTVisitor {
*/
private boolean temp_processingArrayIndex;

/**
* annotations collected for a class
*/
private List<ClassAnnotation> class_annotations;
/**
* functionalInterface methods add the name$ qualifier even if they are
* parameterized
Expand Down Expand Up @@ -297,13 +302,13 @@ private Java2ScriptVisitor setInnerGlobals(Java2ScriptVisitor parent, ASTNode no
package_methodStackForFinals = parent.package_methodStackForFinals;
package_blockLevel = parent.package_blockLevel;
package_finalVars = parent.package_finalVars;

class_visitedVars = parent.class_visitedVars;

// inner class temporary visitor business

this$0Name = parent.class_fullName;
innerNode = node;

return this;
}

Expand Down Expand Up @@ -948,7 +953,7 @@ public boolean visit(IfStatement node) {
*
*/
public boolean visit(Initializer node) {
if (NativeDoc.checkj2sIgnore(node)) {
if (checkj2sIgnoreAndJAXB(node)) {
return false;
}
node.getBody().accept(this);
Expand All @@ -969,7 +974,7 @@ public boolean visit(LabeledStatement node) {
@SuppressWarnings("unchecked")
public boolean visit(MethodDeclaration node) {
IMethodBinding mBinding = node.resolveBinding();
if (mBinding == null || NativeDoc.checkj2sIgnore(node))
if (mBinding == null || checkj2sIgnoreAndJAXB(node))
return false;
processMethodDeclaration(mBinding, node.parameters(), node.getBody(), node.isConstructor(), NOT_LAMBDA);
return false;
Expand Down Expand Up @@ -1688,6 +1693,9 @@ private void addClassOrInterface(ASTNode node, ITypeBinding binding, List<?> bod

// set up key fields and local variables

if (isLocal || isClass) {
checkj2sIgnoreAndJAXB((TypeDeclaration) node);
}
ITypeBinding oldBinding = null;
String oldShortClassName = null, this$0Name0 = null, finalShortClassName, finalPackageName;
if (isTopLevel) {
Expand Down Expand Up @@ -1927,7 +1935,7 @@ private void addClassOrInterface(ASTNode node, ITypeBinding binding, List<?> bod
// in Class A.

if (isField || element instanceof Initializer) {
if ((isInterface || isStatic(element)) && !NativeDoc.checkj2sIgnore(element)) {
if ((isInterface || isStatic(element)) && !checkj2sIgnoreAndJAXB(element)) {
lstStatic.add(element);
if (isField)
addFieldDeclaration((FieldDeclaration) element, FIELD_DECL_STATIC_DEFAULTS);
Expand Down Expand Up @@ -1977,7 +1985,7 @@ private void addClassOrInterface(ASTNode node, ITypeBinding binding, List<?> bod
for (Iterator<?> iter = bodyDeclarations.iterator(); iter.hasNext();) {
BodyDeclaration element = (BodyDeclaration) iter.next();
if ((element instanceof FieldDeclaration || element instanceof Initializer) && !isStatic(element)
&& !NativeDoc.checkj2sIgnore(element)) {
&& !checkj2sIgnoreAndJAXB(element)) {
if (element instanceof FieldDeclaration)
addFieldDeclaration((FieldDeclaration) element, FIELD_DECL_NONSTATIC_ALL);
else
Expand Down Expand Up @@ -2057,6 +2065,9 @@ private void addClassOrInterface(ASTNode node, ITypeBinding binding, List<?> bod
// add any recently defined static field definitions, assert strings
// and Enum constants

if (class_annotations != null)
ClassAnnotation.addClassAnnotations(class_annotations, trailingBuffer);

buffer.append(trailingBuffer); // also writes the assert string
if (isAnonymous) {
// if anonymous, restore old static def buffer
Expand All @@ -2077,7 +2088,7 @@ private void addClassOrInterface(ASTNode node, ITypeBinding binding, List<?> bod
}

getJ2sJavadoc(node, false);

if (!isTopLevel) {
addAnonymousFunctionWrapper(false);
if (isAnonymous) {
Expand Down Expand Up @@ -3596,12 +3607,8 @@ static boolean isStatic(IBinding b) {
return b != null && Modifier.isStatic(b.getModifiers());
}

/**
* @param b
* @return
*/
static boolean isStatic(IMethodBinding b) {
return b != null && Modifier.isStatic(b.getModifiers());
static boolean isTransient(IBinding b) {
return b != null && Modifier.isTransient(b.getModifiers());
}

static boolean isStatic(BodyDeclaration b) {
Expand Down Expand Up @@ -5298,6 +5305,64 @@ private List<Javadoc> getJ2sJavadoc(ASTNode node, boolean isPre) {
return docs;
}

/**
* @param node
* @return true if we have @j2sIngore for this BodyDeclaration
*/
protected boolean checkj2sIgnoreAndJAXB(BodyDeclaration node) {
return checkAnnotations(node, "@j2sIgnore") != null;
}

/**
* Method with "j2s*" tag.
*
* @param node
* @return
*/
private Object checkAnnotations(BodyDeclaration node, String tagName) {
Javadoc javadoc = node.getJavadoc();
if (javadoc != null) {
List<?> tags = javadoc.tags();
if (tags.size() != 0) {
for (Iterator<?> iter = tags.iterator(); iter.hasNext();) {
TagElement tagEl = (TagElement) iter.next();
if (tagName.equals(tagEl.getTagName())) {
return tagEl;
}
}
}
}
List<?> modifiers = node.modifiers();
if (modifiers != null && modifiers.size() > 0) {
for (Iterator<?> iter = modifiers.iterator(); iter.hasNext();) {
Object obj = iter.next();
if (obj instanceof Annotation) {
Annotation annotation = (Annotation) obj;
String qName = annotation.getTypeName().getFullyQualifiedName();
int idx = qName.indexOf("J2S");
if (idx >= 0) {
String annName = qName.substring(idx);
annName = annName.replaceFirst("J2S", "@j2s");
if (annName.startsWith(tagName)) {
return annotation;
}
} else if (!qName.equals("Override")
&& !qName.equals("Deprecated")
&& !qName.equals("Suppress")
&& !qName.equals("XmlTransient")
) {
if (class_annotations == null)
class_annotations = new ArrayList<ClassAnnotation>();
ClassAnnotation ann = ClassAnnotation.newAnnotation(qName, annotation, node);
if (ann != null)
class_annotations.add(ann);
}
}
}
}
return null;
}

/////////////////////////////

/**
Expand Down Expand Up @@ -6057,7 +6122,61 @@ static boolean fieldNameCoversMethod(String fieldName) {

}

public static class NativeDoc {
static class ClassAnnotation {

protected BodyDeclaration node;
protected Annotation annotation;
private String qName;

public static ClassAnnotation newAnnotation(String qName, Annotation annotation, BodyDeclaration node) {

// TODO Auto-generated method stub
return null;
}

protected ClassAnnotation(String qName, Annotation annotation, BodyDeclaration node) {
System.out.println(">>>>" + qName + " " + annotation.getClass().getName() + " " + annotation);
this.qName = qName;
this.annotation = annotation;
this.node = node;
}

public static void addClassAnnotations(List<ClassAnnotation> class_annotations, TrailingBuffer trailingBuffer) {
if (class_annotations == null)
return;
int pt = 0;
for (int i = 0; i < class_annotations.size(); i++) {
ClassAnnotation a = class_annotations.get(i);
String str = a.annotation.toString();
if (str.startsWith("@SuppressWarnings"))
continue;
String nodeType = a.qName;
String varName = null;
if (a.node instanceof FieldDeclaration) {
FieldDeclaration field = (FieldDeclaration) a.node;
List<?> fragments = field.fragments();
VariableDeclarationFragment identifier = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding var = identifier.resolveBinding();
nodeType = (var.getType().isArray() ? "[array]" : field.getType().toString());
varName = var.getName();
} else if (a.node instanceof MethodDeclaration) {
MethodDeclaration method = (MethodDeclaration) a.node;
IMethodBinding var = method.resolveBinding();
ITypeBinding type = var.getReturnType();
nodeType = (type.isArray() ? "[array]" : type.getName());
varName = "M:" + var.getName();
}
trailingBuffer.append(pt++ == 0 ? "C$.__ANN__ = [\n " : " ,");
trailingBuffer.append("[" + (varName == null ? null : "'" + varName + "'")
+ ",'" + nodeType + "','" + str + "']\n");
}
if (pt > 0)
trailingBuffer.append("];\n");
}

}

static class NativeDoc {

/**
* prepare a list that alternates [javadoc element javadoc element ... ]
Expand Down Expand Up @@ -6196,54 +6315,6 @@ private static boolean addJ2SSourceForTag(StringBuffer buffer, TagElement tag, b
return true;
}

/**
* @param node
* @return true if we have @j2sIngore for this BodyDeclaration
*/
protected static boolean checkj2sIgnore(BodyDeclaration node) {
return getJ2SKeepOrIgnore(node, "@j2sIgnore") != null;
}

/**
* Method with "j2s*" tag.
*
* @param node
* @return
*/
private static Object getJ2SKeepOrIgnore(BodyDeclaration node, String tagName) {
Javadoc javadoc = node.getJavadoc();
if (javadoc != null) {
List<?> tags = javadoc.tags();
if (tags.size() != 0) {
for (Iterator<?> iter = tags.iterator(); iter.hasNext();) {
TagElement tagEl = (TagElement) iter.next();
if (tagName.equals(tagEl.getTagName())) {
return tagEl;
}
}
}
}
List<?> modifiers = node.modifiers();
if (modifiers != null && modifiers.size() > 0) {
for (Iterator<?> iter = modifiers.iterator(); iter.hasNext();) {
Object obj = iter.next();
if (obj instanceof Annotation) {
Annotation annotation = (Annotation) obj;
String qName = annotation.getTypeName().getFullyQualifiedName();
int idx = qName.indexOf("J2S");
if (idx >= 0) {
String annName = qName.substring(idx);
annName = annName.replaceFirst("J2S", "@j2s");
if (annName.startsWith(tagName)) {
return annotation;
}
}
}
}
}
return null;
}

}

/**
Expand Down
5 changes: 5 additions & 0 deletions sources/net.sf.j2s.java.core/dist/DEV_NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BH 2018.10.01

fix for AWT applets and frames not automatically
activating their childrens' mouse listeners.

Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
4 changes: 4 additions & 0 deletions sources/net.sf.j2s.java.core/src/a2s/A2SEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Container;
import java.awt.Event;
import java.awt.Point;
import java.awt.event.ActionEvent;
Expand Down Expand Up @@ -39,6 +40,9 @@ public A2SEvent(AWTEvent e) {
public void run() {
Event e = this.e;
Component target = (Component) this.target;
if (target instanceof Container)
target = ((Container)target).getMouseEventTarget(e.x, e.y, true, null, false);


/**
* Otherwise the states have not changed
Expand Down
Loading