Skip to content

Commit f5c4713

Browse files
committed
// BH 2022.06.27 -- 3.3.1-v5 fixes missing method annotations
1 parent f21a6f0 commit f5c4713

File tree

13 files changed

+59
-20
lines changed

13 files changed

+59
-20
lines changed
23.2 KB
Binary file not shown.
81 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220527103831
1+
20220627232852
23.2 KB
Binary file not shown.
81 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220527103831
1+
20220627232852

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ public class CorePlugin extends Plugin {
2525
* "net.sf.j2s.core.jar" not "net.sf.j2s.core.3.2.5"
2626
*
2727
*/
28-
public static String VERSION = "3.3.1-v4";
28+
public static String VERSION = "3.3.1-v5";
2929

3030
// if you change the x.x.x number, be sure to also indicate that in
3131
// j2sApplet.js and also (Bob only) update.bat, update-clean.bat
3232

33+
// BH 2022.06.27 -- 3.3.1-v5 fixes missing method annotations
3334
// BH 2022.01.17 -- 3.3.1-v4 fixes default interface methods referencing their own static fields
3435
// BH 2021.01.14 -- 3.3.1-v3 fixes missing finals for nested () -> {...}
3536
// BH 2021.01.03 -- 3.3.1-v2 adds @j2sAsync adds async for function - experimental

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class Java2ScriptCompiler {
123123
private static final String J2S_COMPILER_READ_ANNOTATIONS = "j2s.compiler.read.annotations";
124124
private static final String J2S_COMPILER_READ_ANNOTATIONS_DEFAULT = "true";
125125
private static final String J2S_COMPILER_IGNORED_ANNOTATIONS = "j2s.compiler.ignored.annotations";
126-
private static final String J2S_COMPILER_IGNORED_ANNOTATIONS_DEFAULT =
126+
static final String J2S_COMPILER_IGNORED_ANNOTATIONS_DEFAULT =
127127
"CallerSensitive;"
128128
+ "ConstructorProperties;"
129129
+ "Deprecated;"
@@ -135,7 +135,8 @@ class Java2ScriptCompiler {
135135
+ "Inherited;"
136136
+ "Native;"
137137
+ "Repeatable;"
138-
+ "Retention;";
138+
+ "Retention;"
139+
+ "Transient;";
139140

140141
private static final String J2S_COMPILER_NONQUALIFIED_PACKAGES = "j2s.compiler.nonqualified.packages";
141142
private static final String J2S_COMPILER_NONQUALIFIED_PACKAGES_DEFAULT = "<none>";

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,7 @@ public class Java2ScriptVisitor extends ASTVisitor {
373373
* list of annotations to ignore or null to ignore ALL
374374
*
375375
*/
376-
private static String global_ignoredAnnotations = ";" + "CallerSensitive;" + "ConstructorProperties;"
377-
+ "Deprecated;" + "Override;" + "SaveVarargs;" + "SuppressWarnings;";
376+
private static String global_ignoredAnnotations = Java2ScriptCompiler.J2S_COMPILER_IGNORED_ANNOTATIONS_DEFAULT;
378377

379378
public static void setDebugging(boolean isDebugging) {
380379
global_j2sFlag_isDebugging = isDebugging;
@@ -2457,6 +2456,8 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
24572456
List<EnumConstantDeclaration> enums = (isEnum ? new ArrayList<>() : null);
24582457
List<FieldDeclaration> fields = (haveFieldMethodAnnotations || isInterface || isLambda || isEnum ? null
24592458
: new ArrayList<>());
2459+
2460+
24602461
List<IMethodBinding> methods = (haveFieldMethodAnnotations || isAnnotation || fields != null ? new ArrayList<>()
24612462
: null);
24622463

@@ -6312,9 +6313,9 @@ private boolean checkAnnotations(BodyDeclaration node, int mode) {
63126313
if (obj instanceof Annotation) {
63136314
if (!addAnnotation((Annotation) obj, node, mode))
63146315
return false;
6316+
}
63156317
}
63166318
}
6317-
}
63186319
return true;
63196320
}
63206321

@@ -7111,7 +7112,7 @@ public static void addClassAnnotations(Java2ScriptVisitor visitor, int accessTyp
71117112
if (methods.contains(mBinding))
71127113
methods.remove(mBinding);
71137114
if (accessType != NOT_JAXB)
7114-
mBinding = getJAXBGetMethod(mBinding, methods, false);
7115+
mBinding =getJAXBGetMethod(accessType, mBinding, methods, false);
71157116
if (mBinding == null)
71167117
continue;
71177118
varName = "M:" + mBinding.getName();
@@ -7190,11 +7191,11 @@ private static String annotationNameValue(String name, Object value) {
71907191
return str;
71917192
}
71927193

7193-
private static IMethodBinding getJAXBGetMethod(IMethodBinding v, List<IMethodBinding> methods,
7194+
private static IMethodBinding getJAXBGetMethod(int accessType, IMethodBinding v, List<IMethodBinding> methods,
71947195
boolean returnVar2) {
71957196
String varName = v.getName();
71967197
// check for matching get/is and set
7197-
if (varName.startsWith("create")) {
7198+
if (accessType == ANNOTATION_TYPE_UNKNOWN || varName.startsWith("create")) {
71987199
return v;
71997200
}
72007201
if (varName.startsWith("set")) {
@@ -7266,7 +7267,7 @@ private static void addImplicitJAXBFieldsAndMethods(int accessType, StringBuffer
72667267
if (accessType != JAXB_TYPE_FIELD) {
72677268
for (int i = 0; i < methods.size(); i++) {
72687269
IMethodBinding m = methods.get(i);
7269-
IMethodBinding m2 = getJAXBGetMethod(m, methods, true);
7270+
IMethodBinding m2 = getJAXBGetMethod(-1, m, methods, true);
72707271
if (m2 == null)
72717272
continue;
72727273
boolean isPublic = (Modifier.isPublic(m.getModifiers())

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ j2s.allow.sync.thread=true
77
j2s.compiler.read.annotations=true
88

99
# customizable list for what annotations to skip
10-
j2s.compiler.ignored.annotations=CallerSensitive;ConstructorProperties;Deprecated;Override;SaveVarargs;SuppressWarnings;
10+
j2s.compiler.ignored.annotations=CallerSensitive;ConstructorProperties;Deprecated;Override;SafeVarargs;SuppressWarnings;FunctionalInterface;Documented;Inherited;Native;Repeatable;Retention;Transient;
1111

1212
#j2s.compiler.nonqualified.packages=org.w3c.dom
1313

0 commit comments

Comments
 (0)