Skip to content

Commit 5f11504

Browse files
author
sebastigurin
committed
commit my recent fixes to braches_3.6 to trunk
1 parent cea1c27 commit 5f11504

4 files changed

Lines changed: 33 additions & 11 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,8 @@ public boolean visit(TryStatement node) {
11361136
buffer.append("{\r\n");
11371137
scopeAdded = true;
11381138
}
1139-
buffer.append("if (Clazz.instanceOf (" + catchEName + ", ");
1139+
buffer.append("if (Clazz.exceptionOf (" + catchEName + ", ");//sgurin : isExceptionOf compiler support.
1140+
//old code was: buffer.append("if (Clazz.instanceOf (" + catchEName + ", ");
11401141
type.accept(this);
11411142
buffer.append(")) ");
11421143
} else {

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

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,18 +1855,34 @@ public boolean visit(MethodInvocation node) {
18551855
buffer.append(", ");
18561856
}
18571857
boolean needBrackets = true;
1858-
//if (args.size() == 1) {
1858+
1859+
//sgurin: corrected bug when vararg parameter is an empty array.
1860+
if (args.size() == 0) {
1861+
if (needBrackets) buffer.append("[]");
1862+
}
1863+
else {
18591864
Expression arg = (Expression) args.get(args.size() - 1);
18601865
ITypeBinding resolveTypeBinding = arg.resolveTypeBinding();
1861-
if (resolveTypeBinding != null && resolveTypeBinding.isArray()) {
1862-
needBrackets = false;
1863-
}
1864-
//}
1865-
if (needBrackets) buffer.append("[");
1866-
//IMethodBinding methodDeclaration = node.resolveMethodBinding();
1867-
//visitMethodParameterList(node.arguments(), methodDeclaration, paramTypes.length - 1, size);
1868-
visitList(args, ", ", paramTypes.length - 1, size);
1869-
if (needBrackets) buffer.append("]");
1866+
if (resolveTypeBinding != null && resolveTypeBinding.isArray())
1867+
needBrackets = false;
1868+
if (needBrackets) buffer.append("[");
1869+
visitList(args, ", ", paramTypes.length - 1, size);
1870+
if (needBrackets) buffer.append("]");
1871+
}
1872+
//old code:
1873+
// //if (args.size() == 1) {
1874+
// Expression arg = (Expression) args.get(args.size() - 1);
1875+
// ITypeBinding resolveTypeBinding = arg.resolveTypeBinding();
1876+
// if (resolveTypeBinding != null && resolveTypeBinding.isArray()) {
1877+
// needBrackets = false;
1878+
// }
1879+
// //}
1880+
// if (needBrackets) buffer.append("[");
1881+
// //IMethodBinding methodDeclaration = node.resolveMethodBinding();
1882+
// //visitMethodParameterList(node.arguments(), methodDeclaration, paramTypes.length - 1, size);
1883+
// visitList(args, ", ", paramTypes.length - 1, size);
1884+
// if (needBrackets) buffer.append("]");
1885+
18701886
} else {
18711887
IMethodBinding methodDeclaration = node.resolveMethodBinding();
18721888
visitMethodParameterList(node.arguments(), methodDeclaration);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,10 @@ public boolean visit(MethodInvocation node) {
956956
optionals.add(qn);
957957
}
958958
}
959+
//sgurin: fix for bug http://sourceforge.net/tracker/?func=det ail&aid=3037341&group_id=155436&atid=795800
960+
String methodOwnerClassName = resolveMethodBinding.getDeclaringClass().getQualifiedName();
961+
if(methodOwnerClassName!=null && !methodOwnerClassName.equals(""))
962+
requires.add(methodOwnerClassName);
959963
}
960964
return super.visit(node);
961965
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ public static String[] getClazzAbbrMap() {
531531
"Clazz.prepareFields", "Y", //
532532
"Clazz.newArray", "A", //
533533
"Clazz.instanceOf", "O", //
534+
"Clazz.exceptionOf", "e", //sgurin
534535
"Clazz.inheritArgs", "G", //
535536
"Clazz.checkPrivateMethod", "X", //
536537
"Clazz.makeFunction", "Q", //

0 commit comments

Comments
 (0)