Skip to content

Commit 4f81ff0

Browse files
authored
Merge pull request #153 from BobHanson/master
3.2.7 fixes; tweaks of j2sApplet.js and j2sClazz.js,3.2.7_v4 automatically switches extends Label and JLabel
2 parents 4b58a76 + c7b7ae8 commit 4f81ff0

File tree

16 files changed

+148
-41
lines changed

16 files changed

+148
-41
lines changed
132 Bytes
Binary file not shown.
156 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200113205904
1+
20200116221246
132 Bytes
Binary file not shown.
156 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200113205904
1+
20200116221246

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135

136136
// TODO: superclass inheritance for JAXB XmlAccessorType
137137

138+
//BH 2020.01.16 -- 3.2.7-v4 replaces extends java.awt.Component and javax.swing.JComponent
138139
//BH 2020.01.12 -- 3.2.7-v3 fixes JAXB annotation marshalling for 3.2.7
139140
//BH 2020.01.11 -- 3.2.7-v3 corrects and rewrites synthetic bridge creation with much cleaner heap usage
140141
//BH 2020.01.09 -- 3.2.7-v2 introduces @j2sAlias as a way of adding a custom method name, as in exports.
@@ -2004,7 +2005,8 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
20042005
this$0Name0 = this$0Name;
20052006
this$0Name = null;
20062007
finalShortClassName = getFinalJ2SClassName(
2007-
(isLambda ? getMyJavaClassNameLambda(true) : getUnreplacedJavaClassNameQualified(binding)), FINAL_P);
2008+
(isLambda ? getMyJavaClassNameLambda(true) : getUnreplacedJavaClassNameQualified(binding)),
2009+
FINAL_P);
20082010
if (finalShortClassName.startsWith("P$.")) {
20092011
// java.lang.x will return x, not P$.x
20102012
finalShortClassName = finalShortClassName.substring(3);
@@ -2143,14 +2145,24 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
21432145
} else {
21442146
hasDependents = true;
21452147
String superclassName = getUnreplacedJavaClassNameQualified(superclass);
2146-
if (superclassName == null || superclassName.length() == 0 || "java.lang.Object".equals(superclassName)) {
2148+
switch (superclassName == null ? "" : superclassName) {
2149+
case "":
2150+
case "java.lang.Object":
21472151
buffer.append("null");
2148-
} else {
2152+
break;
2153+
case "java.awt.Component":
2154+
buffer.append("'java.awt.Label'");
2155+
break;
2156+
case "javax.swing.JComponent":
2157+
buffer.append("'javax.swing.JLabel'");
2158+
break;
2159+
default:
21492160
if (isAnonymous) {
21502161
buffer.append(getFinalJ2SClassNameQualifier(null, superclass, superclassName, FINAL_ESCAPE));
21512162
} else {
21522163
buffer.append(getFinalInnerClassList(superclass, superclassName));
21532164
}
2165+
break;
21542166
}
21552167
}
21562168

@@ -2183,7 +2195,8 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
21832195
int pt = buffer.length();
21842196
while (!b.isTopLevel()) {
21852197
b = b.getDeclaringClass();
2186-
buffer.insert(pt, "'" + getFinalJ2SClassName(getUnreplacedJavaClassNameQualified(b), FINAL_RAW) + "',");
2198+
buffer.insert(pt,
2199+
"'" + getFinalJ2SClassName(getUnreplacedJavaClassNameQualified(b), FINAL_RAW) + "',");
21872200
}
21882201
}
21892202
buffer.append("'");
@@ -2527,7 +2540,7 @@ private void processAnnotationTypeMemberDeclaration(AnnotationTypeMemberDeclarat
25272540
String retName = (ret.isPrimitive() ? ret.getName() : j2sNonPrimitiveName(ret, true));
25282541
buffer.append("a.push(['" + name + "','" + retName + (isArray ? "[]" : "") + "',");
25292542
if (def == null) {
2530-
if (ret.isPrimitive()) {
2543+
if (!isArray && ret.isPrimitive()) {
25312544
switch (ret.getName()) {
25322545
case "char":
25332546
buffer.append("'\0'");
@@ -2546,7 +2559,7 @@ private void processAnnotationTypeMemberDeclaration(AnnotationTypeMemberDeclarat
25462559
// buffer.append("\"" + mbinding.getAnnotations() + "\"");
25472560
//}
25482561
}
2549-
} else if (ret.isAnnotation()){
2562+
} else if (!isArray && ret.isAnnotation()){
25502563
buffer.append("'@" + getFinalJ2SClassName(getUnreplacedJavaClassNameQualified(def.resolveTypeBinding()), FINAL_RAW) + "'");
25512564
} else {
25522565
def.accept(this);
132 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/sun/reflect/annotation/AnnotationParser.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ private static Object boxValue(Object val, Class<?> type) {
381381
return val;
382382
}
383383

384-
static Map<Class<? extends Annotation>, Annotation> parseAnnotations(String name, Class<?> c, boolean isMethod) {
384+
static Map<Class<? extends Annotation>, Annotation> parseAnnotations(String name, Class<?> c,
385+
boolean isMethod) {
385386
Object[][] __ANN_REC__ = getAnnotations(name, c.$clazz$, isMethod);
386387
if (__ANN_REC__ == null)
387388
return Collections.EMPTY_MAP;
@@ -390,15 +391,17 @@ static Map<Class<? extends Annotation>, Annotation> parseAnnotations(String name
390391
Map<Class<? extends Annotation>, Annotation> result = new LinkedHashMap<Class<? extends Annotation>, Annotation>();
391392
// note that qnames will be one longer than atData after fixing
392393
String[] qnames = getQNames(__ANN_REC__);
393-
String[] atData = getAtCodes(__ANN_REC__);
394-
for (int i = atData.length; --i >= 0;) {
395-
Annotation a = createAnnotation(qnames[i], atData[i]);
396-
if (a != null) {
397-
Class<? extends Annotation> klass = a.getClass();
398-
if (
399-
// AnnotationType.getInstance(klass).retention() == RetentionPolicy.RUNTIME &&
400-
result.put(klass, a) != null) {
401-
throw new AnnotationFormatError("Duplicate annotation for class: " + klass + ": " + a);
394+
if (qnames != null) { // @Xml... may have no qname data
395+
String[] atData = getAtCodes(__ANN_REC__);
396+
for (int i = atData.length; --i >= 0;) {
397+
Annotation a = createAnnotation(qnames[i], atData[i]);
398+
if (a != null) {
399+
Class<? extends Annotation> klass = a.getClass();
400+
if (
401+
// AnnotationType.getInstance(klass).retention() == RetentionPolicy.RUNTIME &&
402+
result.put(klass, a) != null) {
403+
throw new AnnotationFormatError("Duplicate annotation for class: " + klass + ": " + a);
404+
}
402405
}
403406
}
404407
}

sources/net.sf.j2s.java.core/src/swingjs/xml/JSJAXBClass.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ private void removeField(String javaName) {
214214
for (int i = fields.size(); --i >= 0;) {
215215
if (javaName.equals(fields.get(i).javaName)) {
216216
fields.remove(i);
217-
System.out.println("jsjaxbclass (ignored)");
218217
marshallerFieldMap.remove(javaName);
219218
break;
220219
}

0 commit comments

Comments
 (0)