135135
136136// TODO: superclass inheritance for JAXB XmlAccessorType
137137
138+ //BH 2020.03.21 -- 3.2.9-v1e better v1c
139+ //BH 2020.03.20 -- 3.2.9-v1d proper check for new String("x") == "x" (should be false), but new integer(3) == 3 (true)
138140//BH 2020.03.20 -- 3.2.9-v1c more efficient static call from 3.2.9-v1a
139141//BH 2020.02.26 -- 3.2.9-v1b allows (byte) = (byte) to not use |0
140142//BH 2020.02.20 -- 3.2.9-v1a order of 1st two parameters in new_ should be reversed
@@ -3259,7 +3261,7 @@ public boolean visit(Assignment node) {
32593261 }
32603262 } else {
32613263 // just add the right operand
3262- addOperandWithDoc (right , leftIsString );
3264+ addOperandWithJ2SDoc (right , leftIsString );
32633265 }
32643266 if (needNewStaticParenthesis ) {
32653267 buffer .append (")" );
@@ -3564,6 +3566,7 @@ public boolean visit(InfixExpression node) {
35643566 boolean isToString = (expTypeName .indexOf ("String" ) >= 0 );
35653567
35663568 String operator = node .getOperator ().toString ();
3569+
35673570 boolean isBitwise = isBitwiseBinaryOperator (node );
35683571 boolean isComparison = (!isBitwise && "!==<=>=" .indexOf (operator ) >= 0 );
35693572 ITypeBinding leftTypeBinding = left .resolveTypeBinding ();
@@ -3591,9 +3594,14 @@ public boolean visit(InfixExpression node) {
35913594 post = ')' ;
35923595 buffer .append ("!!(" );
35933596 }
3594-
3597+
35953598 boolean isDirect = isBitwise && !toBoolean && leftIsInt && rightIsInt ;
3596- if (isDirect || isComparison ) {
3599+ // string literal comparison check in 3.2.9.v1d
3600+ boolean isStringComparison = (isComparison
3601+ && !(left instanceof NullLiteral ) && !(right instanceof NullLiteral )
3602+ && isInternOrLiteral (left ) != isInternOrLiteral (right )
3603+ );
3604+ if (isDirect || isComparison && !isStringComparison ) {
35973605
35983606 // we do not have to do a full conversion
35993607 // possibilities include
@@ -3641,7 +3649,7 @@ public boolean visit(InfixExpression node) {
36413649
36423650 // left
36433651
3644- addOperandWithDoc (left , isToString && !isBitwise );
3652+ addOperandWithJ2SDoc (left , isToString && !isBitwise );
36453653 buffer .append (' ' );
36463654 // op
36473655 buffer .append (operator );
@@ -3651,7 +3659,12 @@ public boolean visit(InfixExpression node) {
36513659 }
36523660 buffer .append (' ' );
36533661 // right
3654- if (right instanceof ParenthesizedExpression || getJ2sJavadoc (right , DOC_CHECK_ONLY ) != null ) {
3662+ boolean parenthesize = (
3663+ //isStringComparison ||
3664+ right instanceof ParenthesizedExpression || getJ2sJavadoc (right , DOC_CHECK_ONLY ) != null );
3665+ // if (isStringComparison)
3666+ // buffer.append("new String");
3667+ if (parenthesize ) {
36553668 buffer .append ("(" );
36563669 addJ2SDoc (right );
36573670 if (right instanceof ParenthesizedExpression )
@@ -3677,7 +3690,11 @@ public boolean visit(InfixExpression node) {
36773690 return false ;
36783691 }
36793692
3680- private void addOperandWithDoc (Expression exp , boolean toString ) {
3693+ private boolean isInternOrLiteral (Expression e ) {
3694+ return e instanceof StringLiteral || (e instanceof MethodInvocation ) &&(((MethodInvocation ) e ).resolveMethodBinding ().getName ().equals ("intern" ));
3695+ }
3696+
3697+ private void addOperandWithJ2SDoc (Expression exp , boolean toString ) {
36813698 if (exp instanceof ParenthesizedExpression ) {
36823699 buffer .append ("(" );
36833700 addJ2SDoc (exp );
@@ -6158,20 +6175,20 @@ public List<String> getElementList() {
61586175 header = header
61596176 .replace (",I$=[]" ,
61606177 privateVarString + (package_includes .length () == 0 ? ""
6161- : package_includes .append ("]]," + "$I$=function(i,n,m){return("
6162- + (package_haveStaticArgsReversal [0 ] ? "m?(i=function(f,a){return f.apply(null,a)}($I$(i)[n],m)):" : "" )
6178+ : package_includes .append ("]],"
6179+ + "$I$=function"
6180+ //3.2.9-v1e:
6181+ + (package_haveStaticArgsReversal [0 ] ?
6182+ "(i,n,m){return m?$I$(i)[n].apply(null,m):"
6183+ : "(i,n){return"
6184+ )
6185+ //3.2.9-v1a:
6186+ //+ "(i,n){return"
61636187 + "((i=(I$[i]||(I$[i]=Clazz.load(I$[0][i]))))"
6164- + ",!n&&i.$load$&&Clazz.load(i,2)))"
6165- + ",i};"
6166- //
6167- //
6168- //
6169- // "$I$=function(i,n){return"
6170- // + "(i=(I$[i]||(I$[i]=Clazz.load(I$[0][i])))),"
6171- // + "!n&&i.$load$&&Clazz.load(i,2)," + "i}"
6172- //
6173- //
6174- )));
6188+ + ",!n&&i.$load$&&Clazz.load(i,2)"
6189+ + ",i)"
6190+ + "}"
6191+ )));
61756192 for (int i = 1 ; i < parts .length ; i ++) {
61766193 js = parts [i ];
61776194 int pt = js .indexOf ("\n " );
0 commit comments