Skip to content

Commit 84034b6

Browse files
authored
Merge pull request #47 from BobHanson/yadav1
various fixes
2 parents aaef056 + eecc81a commit 84034b6

File tree

12 files changed

+69
-37
lines changed

12 files changed

+69
-37
lines changed
381 Bytes
Binary file not shown.
-19 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180807100156
1+
20180809173713
381 Bytes
Binary file not shown.
-19 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180807100156
1+
20180809173713

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

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898
import org.eclipse.jdt.core.dom.PrefixExpression;
9999
import org.eclipse.jdt.core.dom.PrimitiveType;
100100
import org.eclipse.jdt.core.dom.PrimitiveType.Code;
101+
102+
import sun.security.ssl.KerberosClientKeyExchange;
103+
101104
import org.eclipse.jdt.core.dom.QualifiedName;
102105
import org.eclipse.jdt.core.dom.QualifiedType;
103106
import org.eclipse.jdt.core.dom.ReturnStatement;
@@ -133,6 +136,8 @@
133136
import org.eclipse.jdt.core.dom.WhileStatement;
134137
import org.eclipse.jdt.core.dom.WildcardType;
135138

139+
// TODO DefaultRowSorter final method changes this.sorter.compare to p$1.compare???
140+
136141
// BH 8/6/2018 -- additional Java 8 fixes; enum $valueOf$S to valueOf$S
137142
// BH 8/1/2018 -- adds interface default methods as C$.$defaults$(C$)
138143
// BH 7/29/2018 -- java.util.stream.Collectors is returning java.util.Collectionthis.b$['java.util.Collection'].add
@@ -589,10 +594,10 @@ private String getClassJavaNameForClass(Type type) {
589594
return getClassJavaNameForClass(qualType.getQualifier()) + "."
590595
+ qualType.getName().getIdentifier();
591596
}
592-
if (type instanceof NameQualifiedType) {
593-
NameQualifiedType nType = (NameQualifiedType) type;
594-
return nType.getQualifier() + "." + nType.getName().getIdentifier();
595-
}
597+
// if (type instanceof NameQualifiedType) {
598+
// NameQualifiedType nType = (NameQualifiedType) type;
599+
// return getClassJavaNameForClass(nType.getQualifier()) + "." + nType.getName().getIdentifier();
600+
// }
596601

597602
if (type instanceof ArrayType)
598603
return getClassJavaNameForClass(((ArrayType) type).getElementType());
@@ -1173,13 +1178,13 @@ private void addMethodInvocation(SimpleName nodeName, List<?> arguments, IMethod
11731178
// I have not found a way to do this with lambda expressions.
11741179
//
11751180
boolean isStatic = isStatic(mBinding);// || expression != null && isStatic(expression.resolveTypeBinding()));
1176-
if (!isStatic && expression instanceof Name) {
1177-
IBinding binding = ((Name) expression).resolveBinding();
1178-
// no, because sometimes these are not fully qualified className =
1179-
// expression.toString();
1180-
// because System.out is the name of a static field, not a class
1181-
isStatic |= isStatic(binding);
1182-
}
1181+
// if (!isStatic && expression instanceof Name) {
1182+
// IBinding binding = ((Name) expression).resolveBinding();
1183+
// // no, because sometimes these are not fully qualified className =
1184+
// // expression.toString();
1185+
// // because System.out is the name of a static field, not a class
1186+
// isStatic |= isStatic(binding);
1187+
// }
11831188
boolean isPrivate = isPrivate(mBinding);
11841189
boolean isPrivateAndNotStatic = isPrivate && !isStatic;
11851190
String privateVar = (isPrivateAndNotStatic ? getPrivateVar(declaringClass, false) : null);
@@ -6326,7 +6331,7 @@ private static boolean addJ2SSourceForTag(StringBuffer buffer, TagElement tag, b
63266331
// end with 1?xxx: to replace anything with xxx
63276332
// /** @j2sNatve ! */true
63286333
// (/** @j2sNative 1?x: */y)
6329-
// /** @j2sNative true || */javaOnly()
6334+
// /** @j2sNative true || */()
63306335

63316336
boolean isInline = code.endsWith("|") || code.endsWith("&") || code.endsWith(":") || code.endsWith("!");
63326337
buffer.append(isInline ? "" : addPrefix ? "{\r\n" : "\r\n");
@@ -6627,21 +6632,33 @@ private void addLambdaMethod(ASTNode lnode, IMethodBinding mBinding) {
66276632
* @param binding
66286633
* @return
66296634
*/
6630-
private static String getPrivateVar(IBinding binding, boolean isClassCompare) {
6631-
String key = binding.getKey(), key0 = null;
6635+
private String getPrivateVar(IBinding binding, boolean isClassCompare) {
6636+
String key = binding.getKey(), key0 = null, key1 = null;
66326637
if (isClassCompare)
66336638
key = "_" + key;
66346639
String p$ = classToPrivateVar.get(key);
66356640
if (p$ == null) {
66366641
key0 = key;
66376642
p$ = classToPrivateVar.get(key = (isClassCompare ? "_" : "") + getNormalizedKey(binding));
66386643
}
6644+
if (p$ == null && !isClassCompare && key.indexOf("[") >= 0) {
6645+
key1 = key;
6646+
p$ = classToPrivateVar.get(key = key.substring(0, key.indexOf("[") + 1) + "]");
6647+
}
66396648
if (p$ == null) {
66406649
classToPrivateVar.put(key, p$ = "p$" + (isClassCompare ? ++privateClassCount : ++privateVarCount));
66416650
classToPrivateVar.put(key0, p$);
6642-
if (!isClassCompare)
6651+
if (!isClassCompare) {
6652+
if (key1 != null)
6653+
classToPrivateVar.put(key1, p$);
6654+
// System.out.println("adding " + p$ + " " + key + " " + key0 + " " + key1);
66436655
privateVarString += "," + p$ + "={}";
6656+
}
66446657
}
6658+
// if (!isClassCompare) {
6659+
// System.out.println(buffer.substring(buffer.length() - 20));
6660+
// System.out.println(">>" + p$ + " " + key + " " + key0 + " " + key1 + "<<");
6661+
// }
66456662
return p$;
66466663
}
66476664

@@ -6653,7 +6670,7 @@ private static String getPrivateVar(IBinding binding, boolean isClassCompare) {
66536670
* @param b
66546671
* @return
66556672
*/
6656-
private static boolean areEqual(IBinding a, IBinding b) {
6673+
private boolean areEqual(IBinding a, IBinding b) {
66576674
return getPrivateVar(a, true).equals(getPrivateVar(b, true));
66586675
}
66596676

381 Bytes
Binary file not shown.

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +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+
{
316326
return Integer.parseInt(s, i);
327+
}
317328
}
318329

319330
public static String[] getTokens(String line) {
@@ -416,7 +427,7 @@ public static String parseTrimmedChecked(String str, int ich, int ichMax) {
416427

417428
// public static double dVal(String s) throws NumberFormatException {
418429
// /**
419-
// * xxxxj2sNative
430+
// * @j2sNative
420431
// *
421432
// * if(s==null)
422433
// * throw new NumberFormatException("null");
@@ -433,7 +444,7 @@ public static String parseTrimmedChecked(String str, int ich, int ichMax) {
433444
//
434445
// public static float fVal(String s) throws NumberFormatException {
435446
// /**
436-
// * xxxxj2sNative
447+
// * @j2sNative
437448
// *
438449
// * return this.dVal(s);
439450
// */
@@ -785,7 +796,7 @@ public static boolean isNonStringPrimitive(Object info) {
785796
// * Note that info will be a primitive in JavaScript
786797
// * but a wrapped primitive in Java.
787798
// *
788-
// * xxxxj2sNative
799+
// * @j2sNative
789800
// *
790801
// * return info[i];
791802
// */
@@ -980,10 +991,11 @@ public static String escUnicode(String str) {
980991
*/
981992
public static String escF(float f) {
982993
String sf = "" + f;
994+
// NaN, Infinity
983995
/**
984996
* @j2sNative
985997
*
986-
* if (sf.indexOf(".") < 0 && sf.indexOf("e") < 0)
998+
* if (sf.indexOf(".") < 0 && sf.indexOf("e") < 0 && sf.indexOf("N") < 0 && sf.indexOf("n") < 0)
987999
* sf += ".0";
9881000
*/
9891001
{

sources/net.sf.j2s.java.core/src/javax/swing/DefaultRowSorter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public abstract class DefaultRowSorter<M, I> extends RowSorter<M> {
126126
/**
127127
* model -> view (JTable)
128128
*/
129-
private int[] modelToView;
129+
private int[] modelToView;
130130

131131
/**
132132
* Comparators specified by column.
@@ -986,7 +986,8 @@ private int compare(int model1, int model2) {
986986
} else {
987987
Comparator c = sortComparators[counter];
988988
// BH 2018 problem here is that comparators are T, but here we have I
989-
result = (/** @j2sNative c == null ? 0 : c.compare$O$O ? c.compare$O$O(v1,v2) : */ c.compare(v1, v2));
989+
// result = (/** @j2sNative c == null ? 0 : c.compare$O$O ? c.compare$O$O(v1,v2) : */ c.compare(v1, v2));
990+
result = c.compare(v1, v2);
990991
}
991992
if (sortOrder == SortOrder.DESCENDING) {
992993
result = -result;
@@ -1390,12 +1391,12 @@ public I getIdentifier() {
13901391
*/
13911392
// NOTE: this class is static so that it can be placed in an array
13921393
private static class Row implements Comparable<Row> {
1393-
DefaultRowSorter sorter;
1394+
private DefaultRowSorter sorter;
13941395
int modelIndex;
13951396

13961397
public Row(DefaultRowSorter sorter, int index) {
13971398
this.sorter = sorter;
1398-
modelIndex = index;
1399+
modelIndex = index;
13991400
}
14001401

14011402
@Override

0 commit comments

Comments
 (0)