Skip to content

Commit 5a57ee9

Browse files
authored
Merge pull request #133 from BobHanson/hanson1
3.2.5-v4 includes transpiler and runtime fixes
2 parents 07ee960 + aabb248 commit 5a57ee9

File tree

16 files changed

+1068
-75
lines changed

16 files changed

+1068
-75
lines changed
230 KB
Binary file not shown.
213 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20191208152303
1+
20191215102844
230 KB
Binary file not shown.
213 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20191208152303
1+
20191215102844

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ 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.2.5-v2";
29-
// BH 2019.12.06 -- 3.2.5.v2 fix for try(resources) not closing those
28+
public static String VERSION = "3.2.5-v4";
29+
// BH 2019.12.15 -- 3.2.5-v4 fix for local class within anonymous class not getting name
30+
// BH 2019.12.12 -- 3.2.5-v3 fix for enums == null in annotations
31+
// BH 2019.12.06 -- 3.2.5-v2 fix for try(resources) not closing those
3032
// BH 2019.11.12 -- 3.2.5-v0 fix for string literals with \n \nn \nnn octals, but "use strict" does not allow for this.
3133
// BH 2019.11.13 -- 3.2.5-v0 fixes static initialization timing. See note in Java2ScriptVisitor
3234
// BH 2019.10.30 -- 3.2.4.09 fixes problem with team...show history...compare having null project.getProject().getLocation()

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

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@
167167
// HashSet as the basis for the {a:a,b:this.$finals$.b} mapping listFinalVariables.
168168
// This fixed all of the stream issues. See Test_Local, Test_java8, Test_Class.
169169

170-
// BH 2019.12.07 3.2.5-v2 fix for lambda expression with $$ must not be cached
170+
// BH 2019.12.15 3.2.5-v4 fix for <? extends Byte> not getting name for boxing
171+
// BH 2019.12.15 3.2.5-v4 fix for local class within anonymous class not getting name
172+
// BH 2019.12.12 3.2.5-v3 fix for enums == null in annotations
173+
// BH 2019.12.07 3.2.5-v3 fix for lambda expression with $$ must not be cached
174+
// BH 2019.12.06 3.2.5-v2 fix for try(resources) not closing those
171175
// BH 2019.11.18 3.2.5-v0 fix for anonymous subclass of a local class not handling finals
172176
// BH 2019.11.18 3.2.5-v0 fix for main method that throws exception not generating html test
173177
// BH 2019.11.18 3.2.5-v0 fix for lambda expressions in classes with annotations
@@ -4437,12 +4441,18 @@ private boolean appendBoxingNode(ASTNode element, boolean toCharCode) {
44374441
// expression is the site of an unboxing conversion
44384442
ITypeBinding typeBinding = exp.resolveTypeBinding();
44394443
if (!typeBinding.isPrimitive()) {
4440-
String name = getJavaClassNameQualified(typeBinding);
4441-
name = (name.indexOf("Integer") >= 0 ? "int"
4442-
: name.indexOf("Character") >= 0 ? "char" : name.replace("java.lang.", "").toLowerCase());
44434444
buffer.append("(");
44444445
element.accept(this);
4445-
buffer.append(toCharCode && name == "char" ? ")" + CHARCODEAT0 : ")." + name + "Value$()");
4446+
if (toCharCode) {
4447+
String name = getJavaClassNameQualified(typeBinding);
4448+
if (toCharCode && name.length() == 0)
4449+
name = typeBinding.getKey();
4450+
if (name.indexOf("Character") >= 0) {
4451+
buffer.append(").intValue$()");
4452+
return true;
4453+
}
4454+
}
4455+
buffer.append(").valueOf()");
44464456
return true;
44474457
}
44484458
}
@@ -4495,11 +4505,22 @@ static String getJavaClassNameQualified(ITypeBinding binding) {
44954505

44964506
if (binding == null)
44974507
return null;
4498-
String binaryName = null, bindingKey;
4499-
if ((binding.isAnonymous() || binding.isLocal()) && (binaryName = binding.getBinaryName()) == null
4508+
String name = null, bindingKey;
4509+
if ((binding.isAnonymous() || binding.isLocal()) && (name = binding.getBinaryName()) == null
45004510
&& (bindingKey = binding.getKey()) != null)
4501-
binaryName = bindingKey.substring(1, bindingKey.length() - 1).replace('/', '.');
4502-
return (binaryName == null ? binding.getQualifiedName() : binaryName);
4511+
name = bindingKey.substring(1, bindingKey.length() - 1).replace('/', '.');
4512+
if (name == null) {
4513+
name = binding.getQualifiedName();
4514+
if (name.length() == 0) {
4515+
name = binding.getBinaryName();
4516+
if (name == null) {
4517+
System.out.println(">>name null?? bn=" + binding.getBinaryName() + " qn=" + binding.getQualifiedName() + " n=" + binding.getName() + " k=" +binding.getKey()
4518+
+ " isAnon" + binding.isAnonymous() + " " + binding.isLocal());
4519+
name = ""; // <? extends Byte>
4520+
}
4521+
}
4522+
}
4523+
return name;
45034524
}
45044525

45054526
private static String getJavaClassNameSuperNoBrackets(ITypeBinding typeBinding) {
@@ -4721,25 +4742,22 @@ String getFinalJ2SClassNameQualifier(Name methodQualifier, ITypeBinding declarin
47214742
* $I$[] dynamic class loading and interfaces, (but interfaces are handled
47224743
* differently).
47234744
*
4724-
* This is a temporary will fix and will fail if the program does not adhere to
4725-
* class/package-capitalization standards.
4726-
*
47274745
* @param packageName Java package name or "_"
47284746
* @param javaClassName
47294747
* @return array listing classes that need to be loaded in order
47304748
*/
47314749
private String getFinalInnerClassList(ITypeBinding javaClass, String javaClassName) {
4732-
if (javaClassName == null)
4750+
String packageName = getPackageName(javaClass);
4751+
if (javaClassName == null) {
47334752
javaClassName = getJavaClassNameQualified(javaClass);
4734-
// called by addClassOrInterface and getFinalClazzLoadI
4753+
System.out.println(">>jcn was null! " + javaClassName);
4754+
// } else if (javaClassName.length() == 0) {
4755+
// // local inner class within an anonymous class
4756+
// javaClassName = javaClass.getBinaryName();
4757+
}
47354758
if (javaClassName.indexOf("$lambda") >= 0)
47364759
return "'" + getFinalJ2SClassName(javaClassName, FINAL_RAW) + "'";
4737-
String name = removeBracketsAndFixNullPackageName(javaClassName);
4738-
String packageName = getPackageName(javaClass);
4739-
// if (name.indexOf(packageName) != 0) {
4740-
// dumpStack("???? packageName " + packageName + " " + name);
4741-
// }
4742-
name = name.substring(packageName.length() + 1);
4760+
String name = removeBracketsAndFixNullPackageName(javaClassName).substring(packageName.length() + 1);
47434761
String[] parts = name.split("\\.");
47444762
String s = packageName + "." + parts[0];
47454763
int len = parts.length;
@@ -5780,10 +5798,12 @@ private void addDummyClassForPackageOnlyFile() {
57805798
}
57815799

57825800
public boolean visit(AnnotationTypeDeclaration node) {
5801+
System.out.println(">>AnnotationTypeDecl " + node);
57835802
return false;
57845803
}
57855804

57865805
public boolean visit(AnnotationTypeMemberDeclaration node) {
5806+
System.out.println(">>AnnotationTypeMembDecl " + node);
57875807
return false;
57885808
}
57895809

@@ -6414,7 +6434,8 @@ public static void addClassAnnotations(int accessType, List<ClassAnnotation> cla
64146434
type = ((TypeDeclaration) a.node).resolveBinding();
64156435
} else if (a.node instanceof FieldDeclaration) {
64166436
FieldDeclaration field = (FieldDeclaration) a.node;
6417-
fields.remove(field);
6437+
if (fields != null)
6438+
fields.remove(field);
64186439
fragments = field.fragments();
64196440
VariableDeclarationFragment identifier = (VariableDeclarationFragment) fragments.get(0);
64206441
IVariableBinding var = identifier.resolveBinding();
@@ -6423,7 +6444,8 @@ public static void addClassAnnotations(int accessType, List<ClassAnnotation> cla
64236444
} else if (a.node instanceof MethodDeclaration) {
64246445
MethodDeclaration method = (MethodDeclaration) a.node;
64256446
IMethodBinding var = method.resolveBinding();
6426-
if (methods.contains(var))
6447+
if (methods != null)
6448+
if (methods.contains(var))
64276449
methods.remove(var);
64286450
if (accessType != TEST_TYPE)
64296451
var = getJAXBGetMethod(var, methods, false);
@@ -6433,7 +6455,8 @@ public static void addClassAnnotations(int accessType, List<ClassAnnotation> cla
64336455
type = var.getReturnType();
64346456
} else if (a.node instanceof EnumConstantDeclaration) {
64356457
EnumConstantDeclaration con = (EnumConstantDeclaration) a.node;
6436-
enums.remove(con);
6458+
if (enums != null)
6459+
enums.remove(con);
64376460
IVariableBinding var = con.resolveVariable();
64386461
varName = var.getName();
64396462
type = var.getType();
230 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/awt/image/DataBuffer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ public abstract class DataBuffer {
8181
/** Tag for int data. */
8282
public static final int TYPE_INT = 3;
8383

84-
// /** Tag for float data. Placeholder for future use. */
85-
// public static final int TYPE_FLOAT = 4;
86-
//
87-
// /** Tag for double data. Placeholder for future use. */
88-
// public static final int TYPE_DOUBLE = 5;
89-
//
84+
/** Tag for float data. Placeholder for future use. */
85+
public static final int TYPE_FLOAT = 4;
86+
87+
/** Tag for double data. Placeholder for future use. */
88+
public static final int TYPE_DOUBLE = 5;
89+
9090
/** Tag for undefined data. */
9191
public static final int TYPE_UNDEFINED = 32;
9292

0 commit comments

Comments
 (0)