@@ -204,6 +204,10 @@ public String getSource() {
204
204
205
205
protected boolean inPrimitiveNoLengthFieldDeclarator = false ;
206
206
207
+ protected boolean inField = false ;
208
+
209
+ protected boolean inArray = false ;
210
+
207
211
protected final SymbolTable symbolTable ;
208
212
209
213
protected String definePrefix ;
@@ -467,7 +471,7 @@ public void visit(ClassOrInterfaceType n, LocalSymbolTable arg) {
467
471
String name = n .getName ();
468
472
if ("String" .equals (name )) {
469
473
if (local ()) {
470
- name = cppTypes .localType ();
474
+ name = inField || inArray ? cppTypes .localType () : cppTypes . weakLocalType ();
471
475
} else if (prefix ()) {
472
476
name = cppTypes .prefixType ();
473
477
} else if (nsUri ()) {
@@ -559,6 +563,10 @@ public void visit(ReferenceType n, LocalSymbolTable arg) {
559
563
if (isConst ()) {
560
564
printer .print ("const " );
561
565
}
566
+ boolean wasInArray = inArray ;
567
+ if (n .getArrayCount () > 0 ) {
568
+ inArray = true ;
569
+ }
562
570
if (noLength ()) {
563
571
n .getType ().accept (this , arg );
564
572
for (int i = 0 ; i < n .getArrayCount (); i ++) {
@@ -586,6 +594,9 @@ public void visit(ReferenceType n, LocalSymbolTable arg) {
586
594
printer .print (">" );
587
595
}
588
596
}
597
+ if (n .getArrayCount () > 0 ) {
598
+ inArray = wasInArray ;
599
+ }
589
600
}
590
601
591
602
public void visit (WildcardType n , LocalSymbolTable arg ) {
@@ -616,6 +627,7 @@ protected boolean isNonToCharArrayMethodCall(Expression exp) {
616
627
}
617
628
618
629
protected void fieldDeclaration (FieldDeclaration n , LocalSymbolTable arg ) {
630
+ inField = true ;
619
631
tempPrinterHolder = printer ;
620
632
printer = staticInitializerPrinter ;
621
633
int modifiers = n .getModifiers ();
@@ -777,6 +789,7 @@ protected void fieldDeclaration(FieldDeclaration n, LocalSymbolTable arg) {
777
789
currentArrayCount = 0 ;
778
790
printer = tempPrinterHolder ;
779
791
inPrimitiveNoLengthFieldDeclarator = false ;
792
+ inField = false ;
780
793
}
781
794
782
795
private void printArrayInit (VariableDeclaratorId variableDeclaratorId ,
@@ -854,6 +867,7 @@ public void visit(ArrayCreationExpr n, LocalSymbolTable arg) {
854
867
// n.getType().accept(this, arg);
855
868
// printTypeArgs(n.getTypeArgs(), arg);
856
869
870
+ inArray = true ;
857
871
if (n .getDimensions () != null ) {
858
872
if (noLength ()) {
859
873
for (Expression dim : n .getDimensions ()) {
@@ -887,6 +901,7 @@ public void visit(ArrayCreationExpr n, LocalSymbolTable arg) {
887
901
"Array initializer as part of array creation not supported. "
888
902
+ n .toString ());
889
903
}
904
+ inArray = false ;
890
905
}
891
906
892
907
public void visit (AssignExpr n , LocalSymbolTable arg ) {
0 commit comments