Skip to content

Commit e930128

Browse files
committed
ZIP reading/writing; fix for super() to Object not adding $init$ call
1 parent 5758cb3 commit e930128

File tree

113 files changed

+1503
-23172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1503
-23172
lines changed

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTKeywordVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ protected final static boolean isMethodQualified(String className, String method
15481548
String s = nonQualifiedClasses[i];
15491549
if (className.equals(s)) {
15501550
// leave selected String methods the same
1551-
return (className.equals("java.lang.String") && "charAt,codePointAt,format,substring,indexOf,lastIndexOf,toUpperCase,toLowerCase,trim,valueOf".indexOf(methodName) < 0);
1551+
return (className.equals("java.lang.String") && "charAt,codePointAt,format,getBytes,substring,indexOf,lastIndexOf,toUpperCase,toLowerCase,trim,valueOf".indexOf(methodName) < 0);
15521552
}
15531553
}
15541554
return true;

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTScriptVisitor.java

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858
import org.eclipse.jdt.core.dom.TypeLiteral;
5959
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
6060

61-
// TODO Clazz._4Name replaces Class.forName$S
62-
6361
// BH 8/19/2017 -- String must implement CharSequence, so all .length() -> .length$()
6462
// BH 8/19/2017 -- varargs logic fixed for missing argument
6563
// BH 8/18/2017 -- array instanceof, reflection, componentType fixes
@@ -1183,24 +1181,24 @@ public boolean visit(MethodDeclaration node) {
11831181
visitList(parameters, ", ");
11841182
buffer.append(") ");
11851183
if (node.isConstructor()) {
1186-
boolean isSuperOrThis = false;
1184+
boolean hasSuperOrThis = false;
11871185
@SuppressWarnings("unchecked")
11881186
List<ASTNode> statements = node.getBody().statements();
11891187
if (statements.size() > 0) {
11901188
ASTNode firstStatement = statements.get(0);
11911189
if (firstStatement instanceof SuperConstructorInvocation
11921190
|| firstStatement instanceof ConstructorInvocation) {
1193-
isSuperOrThis = true;
1191+
hasSuperOrThis = true;
11941192
}
11951193
}
11961194
// BH @j2sIgnoreSuperConstructor removed from options
11971195
// as it is too risky to do this -- lose all initialization.
1198-
IMethodBinding binding = node.resolveBinding();
1199-
boolean existedSuperClass = binding != null && hasSuperClass(binding.getDeclaringClass());
1200-
if (isSuperOrThis) {
1196+
if (hasSuperOrThis) {
12011197
if (!checkJ2STags(node, true))
12021198
node.getBody().accept(this);
12031199
} else {
1200+
IMethodBinding binding = node.resolveBinding();
1201+
boolean existedSuperClass = binding != null && hasSuperClass(binding.getDeclaringClass());
12041202
buffer.append("{\r\n");
12051203
if (existedSuperClass) {
12061204
addSuperConstructor(null, null);
@@ -1804,30 +1802,26 @@ public boolean visit(SingleVariableDeclaration node) {
18041802

18051803
public boolean visit(SuperConstructorInvocation node) {
18061804
IMethodBinding constructorBinding = node.resolveConstructorBinding();
1807-
if (constructorBinding == null) {
1808-
return false;
1809-
}
1810-
ITypeBinding declaringClass = constructorBinding.getDeclaringClass();
1811-
if ("java.lang.Object".equals(declaringClass.getQualifiedName())) {
1812-
return false;
1805+
ITypeBinding declaringClass = (constructorBinding == null ? null : constructorBinding.getDeclaringClass());
1806+
if (constructorBinding != null && declaringClass != null && !"java.lang.Object".equals(declaringClass.getQualifiedName())) {
1807+
// // BH NEVER NEVER NEVER ignore superconstructor, as it
1808+
// includes an <init> call.
1809+
// ASTNode parent = node.getParent();
1810+
// if (parent instanceof Block) {
1811+
// Block methoBlock = (Block) parent;
1812+
// ASTNode methodParent = methoBlock.getParent();
1813+
// if (methodParent instanceof MethodDeclaration) {
1814+
// MethodDeclaration method = (MethodDeclaration) methodParent;
1815+
// if (getJ2STag(method, "@j2sIgnoreSuperConstructor") != null)
1816+
// {
1817+
// return false;
1818+
// }
1819+
// }
1820+
// }
1821+
addSuperConstructor(node, constructorBinding.getMethodDeclaration());
1822+
} else {
1823+
addCallInit();
18131824
}
1814-
// // BH NEVER NEVER NEVER ignore superconstructor, as it includes an <init> call.
1815-
// ASTNode parent = node.getParent();
1816-
// if (parent instanceof Block) {
1817-
// Block methoBlock = (Block) parent;
1818-
// ASTNode methodParent = methoBlock.getParent();
1819-
// if (methodParent instanceof MethodDeclaration) {
1820-
// MethodDeclaration method = (MethodDeclaration) methodParent;
1821-
// if (getJ2STag(method, "@j2sIgnoreSuperConstructor") != null) {
1822-
// return false;
1823-
// }
1824-
// }
1825-
// }
1826-
/*
1827-
* TODO: expression before the "super" should be considered.
1828-
*/
1829-
IMethodBinding methodDeclaration = constructorBinding.getMethodDeclaration();
1830-
addSuperConstructor(node, methodDeclaration);
18311825
return false;
18321826
}
18331827

sources/net.sf.j2s.core/test/src/javajs/J2SIgnoreImport.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

sources/net.sf.j2s.core/test/src/javajs/J2SRequireImport.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

sources/net.sf.j2s.core/test/src/javajs/_README.txt

Lines changed: 0 additions & 38 deletions
This file was deleted.

sources/net.sf.j2s.core/test/src/javajs/api/BytePoster.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

sources/net.sf.j2s.core/test/src/javajs/api/EigenInterface.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

sources/net.sf.j2s.core/test/src/javajs/api/GenericBinaryDocument.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

sources/net.sf.j2s.core/test/src/javajs/api/GenericBinaryDocumentReader.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

sources/net.sf.j2s.core/test/src/javajs/api/GenericCifDataParser.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)