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.
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 @@
20200113205904
20200116221246
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.7/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.7/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.7/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20200113205904
20200116221246
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@

// TODO: superclass inheritance for JAXB XmlAccessorType

//BH 2020.01.16 -- 3.2.7-v4 replaces extends java.awt.Component and javax.swing.JComponent
//BH 2020.01.12 -- 3.2.7-v3 fixes JAXB annotation marshalling for 3.2.7
//BH 2020.01.11 -- 3.2.7-v3 corrects and rewrites synthetic bridge creation with much cleaner heap usage
//BH 2020.01.09 -- 3.2.7-v2 introduces @j2sAlias as a way of adding a custom method name, as in exports.
Expand Down Expand Up @@ -2004,7 +2005,8 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
this$0Name0 = this$0Name;
this$0Name = null;
finalShortClassName = getFinalJ2SClassName(
(isLambda ? getMyJavaClassNameLambda(true) : getUnreplacedJavaClassNameQualified(binding)), FINAL_P);
(isLambda ? getMyJavaClassNameLambda(true) : getUnreplacedJavaClassNameQualified(binding)),
FINAL_P);
if (finalShortClassName.startsWith("P$.")) {
// java.lang.x will return x, not P$.x
finalShortClassName = finalShortClassName.substring(3);
Expand Down Expand Up @@ -2143,14 +2145,24 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
} else {
hasDependents = true;
String superclassName = getUnreplacedJavaClassNameQualified(superclass);
if (superclassName == null || superclassName.length() == 0 || "java.lang.Object".equals(superclassName)) {
switch (superclassName == null ? "" : superclassName) {
case "":
case "java.lang.Object":
buffer.append("null");
} else {
break;
case "java.awt.Component":
buffer.append("'java.awt.Label'");
break;
case "javax.swing.JComponent":
buffer.append("'javax.swing.JLabel'");
break;
default:
if (isAnonymous) {
buffer.append(getFinalJ2SClassNameQualifier(null, superclass, superclassName, FINAL_ESCAPE));
} else {
buffer.append(getFinalInnerClassList(superclass, superclassName));
}
break;
}
}

Expand Down Expand Up @@ -2183,7 +2195,8 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
int pt = buffer.length();
while (!b.isTopLevel()) {
b = b.getDeclaringClass();
buffer.insert(pt, "'" + getFinalJ2SClassName(getUnreplacedJavaClassNameQualified(b), FINAL_RAW) + "',");
buffer.insert(pt,
"'" + getFinalJ2SClassName(getUnreplacedJavaClassNameQualified(b), FINAL_RAW) + "',");
}
}
buffer.append("'");
Expand Down Expand Up @@ -2527,7 +2540,7 @@ private void processAnnotationTypeMemberDeclaration(AnnotationTypeMemberDeclarat
String retName = (ret.isPrimitive() ? ret.getName() : j2sNonPrimitiveName(ret, true));
buffer.append("a.push(['" + name + "','" + retName + (isArray ? "[]" : "") + "',");
if (def == null) {
if (ret.isPrimitive()) {
if (!isArray && ret.isPrimitive()) {
switch (ret.getName()) {
case "char":
buffer.append("'\0'");
Expand All @@ -2546,7 +2559,7 @@ private void processAnnotationTypeMemberDeclaration(AnnotationTypeMemberDeclarat
// buffer.append("\"" + mbinding.getAnnotations() + "\"");
//}
}
} else if (ret.isAnnotation()){
} else if (!isArray && ret.isAnnotation()){
buffer.append("'@" + getFinalJ2SClassName(getUnreplacedJavaClassNameQualified(def.resolveTypeBinding()), FINAL_RAW) + "'");
} else {
def.accept(this);
Expand Down
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ private static Object boxValue(Object val, Class<?> type) {
return val;
}

static Map<Class<? extends Annotation>, Annotation> parseAnnotations(String name, Class<?> c, boolean isMethod) {
static Map<Class<? extends Annotation>, Annotation> parseAnnotations(String name, Class<?> c,
boolean isMethod) {
Object[][] __ANN_REC__ = getAnnotations(name, c.$clazz$, isMethod);
if (__ANN_REC__ == null)
return Collections.EMPTY_MAP;
Expand All @@ -390,15 +391,17 @@ static Map<Class<? extends Annotation>, Annotation> parseAnnotations(String name
Map<Class<? extends Annotation>, Annotation> result = new LinkedHashMap<Class<? extends Annotation>, Annotation>();
// note that qnames will be one longer than atData after fixing
String[] qnames = getQNames(__ANN_REC__);
String[] atData = getAtCodes(__ANN_REC__);
for (int i = atData.length; --i >= 0;) {
Annotation a = createAnnotation(qnames[i], atData[i]);
if (a != null) {
Class<? extends Annotation> klass = a.getClass();
if (
// AnnotationType.getInstance(klass).retention() == RetentionPolicy.RUNTIME &&
result.put(klass, a) != null) {
throw new AnnotationFormatError("Duplicate annotation for class: " + klass + ": " + a);
if (qnames != null) { // @Xml... may have no qname data
String[] atData = getAtCodes(__ANN_REC__);
for (int i = atData.length; --i >= 0;) {
Annotation a = createAnnotation(qnames[i], atData[i]);
if (a != null) {
Class<? extends Annotation> klass = a.getClass();
if (
// AnnotationType.getInstance(klass).retention() == RetentionPolicy.RUNTIME &&
result.put(klass, a) != null) {
throw new AnnotationFormatError("Duplicate annotation for class: " + klass + ": " + a);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ private void removeField(String javaName) {
for (int i = fields.size(); --i >= 0;) {
if (javaName.equals(fields.get(i).javaName)) {
fields.remove(i);
System.out.println("jsjaxbclass (ignored)");
marshallerFieldMap.remove(javaName);
break;
}
Expand Down
61 changes: 61 additions & 0 deletions sources/net.sf.j2s.java.core/src/test/jaxb/FilterBy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2018.12.20 at 11:47:26 AM GMT
//


package test.jaxb;

import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;


/**
* <p>Java class for FilterBy.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* &lt;simpleType name="FilterBy">
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;enumeration value="byLabel"/>
* &lt;enumeration value="byScore"/>
* &lt;enumeration value="byAttribute"/>
* &lt;/restriction>
* &lt;/simpleType>
* </pre>
*
*/
@XmlType(name = "FilterBy", namespace = "www.jalview.org/colours")
@XmlEnum
public enum FilterBy {

@XmlEnumValue("byLabel")
BY_LABEL("byLabel"),
@XmlEnumValue("byScore")
BY_SCORE("byScore"),
@XmlEnumValue("byAttribute")
BY_ATTRIBUTE("byAttribute");
private final String value;

FilterBy(String v) {
value = v;
}

public String value() {
return value;
}

public static FilterBy fromValue(String v) {
for (FilterBy c: FilterBy.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}

}
13 changes: 13 additions & 0 deletions sources/net.sf.j2s.java.core/src/test/jaxb/Root_ORDERED.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {
// "qname",
"filter",
"f5", "position",
"iii",
"IFArray", "IFList",
Expand Down Expand Up @@ -74,6 +75,9 @@ public Root_ORDERED(String name) {

id = "id#1";

filter = FilterBy.BY_LABEL;
filtera = FilterBy.BY_ATTRIBUTE;

hm.put("testing", "TESTING");
hm.put("null", null);
hm.put("map", new SomewhatComplex("map"));
Expand Down Expand Up @@ -162,6 +166,8 @@ public void validate() {
// assert(qname.getLocalPart().equals("name"));
// assert(qname.getNamespaceURI().equals("namespace"));
assert(id.equals("test"));
assert(filter == FilterBy.BY_LABEL);
assert(filtera == FilterBy.BY_ATTRIBUTE);
assert(position.toString().equals("12345678910"));
assert(extraAttr.equals("more&amp;"));
assert(extraElem.equals("more&amp;"));
Expand Down Expand Up @@ -200,6 +206,7 @@ public void validate() {
@XmlSchemaType(name = "xs:unsignedLong") // ignored by JAXB?
private BigInteger position;


@XmlElements({
@XmlElement(name="int", type = Integer.class),
@XmlElement(name="float", type = Float.class)
Expand Down Expand Up @@ -278,6 +285,12 @@ public String toString() {

private final static String x = "date";

@XmlElement
private FilterBy filter;

@XmlAttribute
private FilterBy filtera;

@XmlElement(namespace="")
@XmlSchemaType(name=x)
protected XMLGregorianCalendar creationDate;
Expand Down
33 changes: 17 additions & 16 deletions sources/net.sf.j2s.java.core/src/test/jaxb_ordered_from_JS.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:Root_ORDERED xmlns:ns2="root.ordered" xmlns:ns3="package-namespace" xmlns:ns4="testing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" date="2018-10-20T05:00:00.000Z" byteshex="6465" bytes64="ZGU=" moreAttr="more&amp;amp;" ok="ok" id="test" type="cust">
<ns2:Root_ORDERED xmlns:ns2="root.ordered" xmlns:ns3="package-namespace" xmlns:ns4="testing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" filtera="byAttribute" date="2018-10-20T05:00:00.000Z" byteshex="6465" bytes64="ZGU=" moreAttr="more&amp;amp;" ok="ok" id="test" type="cust">
<ns3:filter xmlns:ns5="www.jalview.org/colours">byLabel</ns3:filter>
<ns3:f5 xsi:type="xs:float">1.25</ns3:f5>
<ns3:f5 xmlns:ns5="stolaf.edu" xsi:type="ns5:objclass" xmlns:ns6="www.jalview.org" id="jaxb2.obj">
<ns6:Obj1>jaxb#Obj1</ns6:Obj1></ns3:f5>
<ns3:f5 xmlns:ns6="stolaf.edu" xsi:type="ns6:objclass" xmlns:ns7="www.jalview.org" id="jaxb2.obj">
<ns7:Obj1>jaxb#Obj1</ns7:Obj1></ns3:f5>
<ns3:position>12345678910</ns3:position>
<ns4:what xsi:type="xs:int">3</ns4:what>
<ns3:int>2</ns3:int>
Expand All @@ -19,9 +20,9 @@
</entry>
<entry>
<key>map</key>
<value xmlns:ns7="st.Olaf" xsi:type="ns7:MoreComplex" xmlns:ns8="www.jalview.org2" ns8:cb="c&quot;&amp;lt;&amp;gt;b&amp;amp; &#8491;" bytes="ZGU=">
<ns7:id>id#map</ns7:id>
<ns7:ca>c"&amp;lt;&amp;gt;b&amp;amp; &#8491;</ns7:ca></value>
<value xmlns:ns8="st.Olaf" xsi:type="ns8:MoreComplex" xmlns:ns9="www.jalview.org2" ns9:cb="c&quot;&amp;lt;&amp;gt;b&amp;amp; &#8491;" bytes="ZGU=">
<ns8:id>id#map</ns8:id>
<ns8:ca>c"&amp;lt;&amp;gt;b&amp;amp; &#8491;</ns8:ca></value>
</entry>
</ns3:hm1>
<ns3:hm2>
Expand All @@ -37,15 +38,15 @@
<value>V3</value>
</entry>
</ns3:hm2>
<ns3:cx xmlns:ns7="st.Olaf" xmlns:ns8="www.jalview.org2" ns8:cb="c&quot;&amp;lt;&amp;gt;b&amp;amp; &#8491;" bytes="Y2U=">
<ns7:id>id##??</ns7:id>
<ns7:ca>c"&amp;lt;&amp;gt;b&amp;amp; &#8491;</ns7:ca></ns3:cx>
<ns3:list0 xmlns:ns7="st.Olaf" xsi:type="ns7:MoreComplex" xmlns:ns8="www.jalview.org2" ns8:cb="c&quot;&amp;lt;&amp;gt;b&amp;amp; &#8491;" bytes="ZGU=">
<ns7:id>id#List</ns7:id>
<ns7:ca>c"&amp;lt;&amp;gt;b&amp;amp; &#8491;</ns7:ca></ns3:list0>
<ns3:cx xmlns:ns8="st.Olaf" xmlns:ns9="www.jalview.org2" ns9:cb="c&quot;&amp;lt;&amp;gt;b&amp;amp; &#8491;" bytes="Y2U=">
<ns8:id>id##??</ns8:id>
<ns8:ca>c"&amp;lt;&amp;gt;b&amp;amp; &#8491;</ns8:ca></ns3:cx>
<ns3:list0 xmlns:ns8="st.Olaf" xsi:type="ns8:MoreComplex" xmlns:ns9="www.jalview.org2" ns9:cb="c&quot;&amp;lt;&amp;gt;b&amp;amp; &#8491;" bytes="ZGU=">
<ns8:id>id#List</ns8:id>
<ns8:ca>c"&amp;lt;&amp;gt;b&amp;amp; &#8491;</ns8:ca></ns3:list0>
<ns3:list0 xsi:type="xs:string">list0[1]</ns3:list0>
<ns3:list0 xsi:type="xs:string">list0[2]</ns3:list0>
<creationDate>2020-01-13-06:00</creationDate>
<creationDate>2020-01-16-06:00</creationDate>
<ns3:c>c</ns3:c>
<ns3:b>b</ns3:b>
<ns3:a>a</ns3:a>
Expand All @@ -57,9 +58,9 @@
<ns3:list1>
<ns3:list xsi:type="xs:string">TESTING</ns3:list>
<ns3:list xsi:type="xs:string">null</ns3:list>
<ns3:list xmlns:ns7="st.Olaf" xsi:type="ns7:MoreComplex" xmlns:ns8="www.jalview.org2" ns8:cb="c&quot;&amp;lt;&amp;gt;b&amp;amp; &#8491;" bytes="ZGU=">
<ns7:id>id#idList#1</ns7:id>
<ns7:ca>c"&amp;lt;&amp;gt;b&amp;amp; &#8491;</ns7:ca></ns3:list>
<ns3:list xmlns:ns8="st.Olaf" xsi:type="ns8:MoreComplex" xmlns:ns9="www.jalview.org2" ns9:cb="c&quot;&amp;lt;&amp;gt;b&amp;amp; &#8491;" bytes="ZGU=">
<ns8:id>id#idList#1</ns8:id>
<ns8:ca>c"&amp;lt;&amp;gt;b&amp;amp; &#8491;</ns8:ca></ns3:list>
<ns3:list xsi:type="xs:boolean">true</ns3:list>
<ns3:list xsi:type="xs:byte">1</ns3:list>
<ns3:list xsi:type="xs:short">2</ns3:list>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns8:RootO xmlns:ns2="www.jalview.org" xmlns:ns3="root.field" xmlns:ns4="package-namespace" xmlns:ns5="testing" xmlns:ns6="st.Olaf" xmlns:ns7="www.jalview.org2" xmlns:ns8="root.ordered" type="cust" id="test" bytes64="ZGU=" byteshex="6465" date="2018-10-20T00:00:00-05:00" moreAttr="more&amp;amp;" ok="ok">
<ns8:RootO xmlns:ns2="www.jalview.org" xmlns:ns3="root.field" xmlns:ns4="package-namespace" xmlns:ns5="testing" xmlns:ns6="st.Olaf" xmlns:ns7="www.jalview.org2" xmlns:ns8="root.ordered" type="cust" id="test" bytes64="ZGU=" byteshex="6465" date="2018-10-20T00:00:00-05:00" filtera="byAttribute" moreAttr="more&amp;amp;" ok="ok">
<ns4:filter>byLabel</ns4:filter>
<ns4:f5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:float">1.25</ns4:f5>
<ns4:f5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns10="stolaf.edu" xsi:type="ns10:objclass" id="jaxb2.obj">
<ns2:Obj1>jaxb#Obj1</ns2:Obj1>
Expand Down Expand Up @@ -49,7 +50,7 @@
</ns4:list0>
<ns4:list0 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">list0[1]</ns4:list0>
<ns4:list0 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">list0[2]</ns4:list0>
<creationDate>2020-01-13-06:00</creationDate>
<creationDate>2020-01-16-06:00</creationDate>
<ns4:c>c</ns4:c>
<ns4:b>b</ns4:b>
<ns4:a>a</ns4:a>
Expand Down
12 changes: 10 additions & 2 deletions sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,16 @@ Clazz.new_ = function(c, args, cl) {

if (c.__CLASS_NAME__ && c.c$)
c = c.c$;
else if (typeof c == "string")
return Clazz.new_(Clazz.load(c));
else if (typeof c == "string") {
// Clazz.new_("path.className")
// Clazz.new_("path.className","$I$O...",[3,"test"]);
switch(arguments.length) {
case 1:
return Clazz.new_(Clazz.load(c));
case 3:
return Clazz.new_(Clazz.load(c)["c$" + args], cl)
}
}

// an inner class will attach arguments to the arguments returned
// Integer will be passed as is here, without c.exClazz, or cl
Expand Down
12 changes: 10 additions & 2 deletions sources/net.sf.j2s.java.core/srcjs/swingjs2.js
Original file line number Diff line number Diff line change
Expand Up @@ -14458,8 +14458,16 @@ Clazz.new_ = function(c, args, cl) {

if (c.__CLASS_NAME__ && c.c$)
c = c.c$;
else if (typeof c == "string")
return Clazz.new_(Clazz.load(c));
else if (typeof c == "string") {
// Clazz.new_("path.className")
// Clazz.new_("path.className","$I$O...",[3,"test"]);
switch(arguments.length) {
case 1:
return Clazz.new_(Clazz.load(c));
case 3:
return Clazz.new_(Clazz.load(c)["c$" + args], cl)
}
}

// an inner class will attach arguments to the arguments returned
// Integer will be passed as is here, without c.exClazz, or cl
Expand Down