Skip to content

Commit 6627dd2

Browse files
hansonrhansonr
authored andcommitted
3.2.2.06 fix for unqualified option in JApplet public methods with $
1 parent 0f5ca5c commit 6627dd2

File tree

12 files changed

+36
-40
lines changed

12 files changed

+36
-40
lines changed
1.17 KB
Binary file not shown.
15 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180915215829
1+
20180916165130
1.17 KB
Binary file not shown.
15 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180915215829
1+
20180916165130

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class CorePlugin extends Plugin {
1919
* register the bundle version properly. So we use VERSION here instead.
2020
*
2121
*/
22-
public static String VERSION = "3.2.2.04";
22+
public static String VERSION = "3.2.2.06";
2323
// 3.2.2.04 2018.08.15 fixing Java->JavaScript "getFinal" code for class names.
2424
// 3.2.2.04 adds support for window-level applets, such as JmolApplet
2525
// 3.2.2.03 adds Java 8 function and stream

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@
132132
import org.eclipse.jdt.core.dom.WhileStatement;
133133
import org.eclipse.jdt.core.dom.WildcardType;
134134

135+
// BH 9/16/2018 -- 3.2.2.06 removes "$" in JApplet public method alternative name
135136
// BH 8/20/2018 -- fix for return (short)++;
136-
137137
// BH 8/19/2018 -- refactored to simplify $finals$
138138
// BH 8/12/2018 -- refactored to simplify naming issues
139139
// BH 8/6/2018 -- additional Java 8 fixes; enum $valueOf$S to valueOf$S
@@ -975,6 +975,10 @@ public boolean visit(MethodDeclaration node) {
975975
return false;
976976
}
977977

978+
private final static int METHOD_FULLY_QUALIFIED = 0;
979+
private final static int METHOD_$_QUALIFIED = 1;
980+
private final static int METHOD_UNQUALIFIED = 2;
981+
978982
/**
979983
* Called by visit(MethodDeclaration) as well as addLambdaMethod().
980984
*
@@ -996,12 +1000,17 @@ private void processMethodDeclaration(IMethodBinding mBinding, List<ASTNode> par
9961000
boolean isPublic = Modifier.isPublic(mods);
9971001
boolean isPrivate = !isPublic && !isConstructor && isPrivate(mBinding);
9981002
boolean isStatic = isStatic(mBinding);
999-
boolean addUnqualified = lambdaType == NOT_LAMBDA && (temp_addUnqualifiedMethod // method call to lambda
1000-
|| isUserApplet && !isConstructor && !isStatic && isPublic
1001-
// public applet methods could never be overloaded in
1002-
// JavaScript anyway.
1003-
);
1004-
String finalName = getFinalMethodNameOrArrayForDeclaration(mBinding, isConstructor, addUnqualified);
1003+
int qualification = (lambdaType != NOT_LAMBDA ? METHOD_FULLY_QUALIFIED
1004+
: temp_addUnqualifiedMethod ? METHOD_$_QUALIFIED
1005+
: isUserApplet && !isConstructor && !isStatic && isPublic ? METHOD_UNQUALIFIED
1006+
: METHOD_FULLY_QUALIFIED);
1007+
1008+
// boolean addUnqualified = lambdaType == NOT_LAMBDA && (temp_addUnqualifiedMethod // method call to lambda
1009+
// || isUserApplet && !isConstructor && !isStatic && isPublic
1010+
// // public applet methods could never be overloaded in
1011+
// // JavaScript anyway.
1012+
// );
1013+
String finalName = getFinalMethodNameOrArrayForDeclaration(mBinding, isConstructor, qualification);
10051014
boolean isMain = isStatic && isPublic && mBinding.getName().equals("main")
10061015
&& mBinding.getKey().endsWith(";.main([Ljava/lang/String;)V");
10071016
if (isMain) {
@@ -4827,10 +4836,11 @@ private static void addGenericClassMethod(String classKey, String methodName, St
48274836
* @param node
48284837
* @param mBinding
48294838
* @param isConstructor
4839+
* @param qualification
48304840
* @return j2s-qualified name or an array of j2s-qualified names
48314841
*/
48324842
private String getFinalMethodNameOrArrayForDeclaration(IMethodBinding mBinding, boolean isConstructor,
4833-
boolean addUnqualified) {
4843+
int qualification) {
48344844
String nodeName = mBinding.getName();
48354845
String methodName = (isConstructor ? "c$" : nodeName);
48364846
String qname = getFinalMethodNameWith$Params(methodName, null, mBinding, null, false, METHOD_NOTSPECIAL);
@@ -4844,12 +4854,12 @@ private String getFinalMethodNameOrArrayForDeclaration(IMethodBinding mBinding,
48444854
METHOD_NOTSPECIAL);
48454855
if (pname != null)
48464856
names.add(pname);
4847-
if (addUnqualified)
4857+
if (qualification == METHOD_FULLY_QUALIFIED)
48484858
names.add(ensureMethod$Name(methodName, mBinding, getJavaClassNameQualified(methodClass)));
48494859
}
4850-
} else if (addUnqualified && !methodName.equals(qname) && !classHasMethod(methodClass, methodName)) {
4860+
} else if (qualification != METHOD_FULLY_QUALIFIED && !methodName.equals(qname) && !classHasMethod(methodClass, methodName)) {
48514861
names = new ArrayList<String>();
4852-
names.add(methodName + (methodName.indexOf("$") >= 0 ? "" : "$"));
4862+
names.add(methodName + (qualification == METHOD_UNQUALIFIED || methodName.indexOf("$") >= 0 ? "" : "$"));
48534863
}
48544864
if (names == null || names.size() == 0)
48554865
return "'" + qname + "'";
@@ -6311,7 +6321,7 @@ private boolean addLambdaMethodReference(MethodReference node, Expression exp) {
63116321
buffer.append("Clazz.newLambda(");
63126322
appendFinalMethodQualifier(exp, declaringlassJavaName, null, FINAL_ESCAPECACHE | FINAL_LAMBDA);
63136323
buffer.append(",");
6314-
buffer.append(getFinalMethodNameOrArrayForDeclaration(mBinding, false, false));
6324+
buffer.append(getFinalMethodNameOrArrayForDeclaration(mBinding, false, METHOD_FULLY_QUALIFIED));
63156325
buffer.append(",'" + lambdaType + "')");
63166326
}
63176327
break;
1.17 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/javajs/util/PT.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,18 +313,18 @@ public static float parseFloat(String str) {
313313
}
314314

315315
public static int parseIntRadix(String s, int i) throws NumberFormatException {
316-
/**
317-
*
318-
* JavaScript uses parseIntRadix
319-
*
320-
* @j2sNative
321-
*
322-
* return Integer.parseIntRadix(s, i);
323-
*
324-
*/
325-
{
316+
// /**
317+
// *
318+
// * JavaScript uses parseIntRadix
319+
// *
320+
// * @j2sNative
321+
// *
322+
// * return Integer.parseIntRadix(s, i);
323+
// *
324+
// */
325+
// {
326326
return Integer.parseInt(s, i);
327-
}
327+
// }
328328
}
329329

330330
public static String[] getTokens(String line) {

0 commit comments

Comments
 (0)