|
54 | 54 | import com.sun.tools.javac.code.Flags;
|
55 | 55 | import com.sun.tools.javac.code.Symbol;
|
56 | 56 | import com.sun.tools.javac.code.Symbol.CompletionFailure;
|
| 57 | +import com.sun.tools.javac.code.Symbol.MethodSymbol; |
57 | 58 | import com.sun.tools.javac.code.Symbol.VarSymbol;
|
58 | 59 | import com.sun.tools.javac.code.Symtab;
|
59 | 60 | import com.sun.tools.javac.code.Type;
|
60 | 61 | import com.sun.tools.javac.code.Type.ClassType;
|
| 62 | +import com.sun.tools.javac.code.Type.MethodType; |
61 | 63 | import com.sun.tools.javac.parser.Scanner;
|
62 | 64 | import com.sun.tools.javac.parser.ScannerFactory;
|
63 | 65 | import com.sun.tools.javac.parser.Tokens.Token;
|
@@ -1073,7 +1075,7 @@ private List<? extends Element> membersOf(AnalyzeTask at, TypeMirror site, boole
|
1073 | 1075 | if (jlObject != null) {
|
1074 | 1076 | result.addAll(membersOf(at, jlObject));
|
1075 | 1077 | }
|
1076 |
| - result.add(createArrayLengthSymbol(at, site)); |
| 1078 | + result.addAll(createArraySymbols(at, site)); |
1077 | 1079 | if (shouldGenerateDotClassItem)
|
1078 | 1080 | result.add(createDotClassSymbol(at, site));
|
1079 | 1081 | return result;
|
@@ -1161,11 +1163,21 @@ private PackageElement createPackageElement(AnalyzeTask at, String packageName)
|
1161 | 1163 | return existing;
|
1162 | 1164 | }
|
1163 | 1165 |
|
1164 |
| - private Element createArrayLengthSymbol(AnalyzeTask at, TypeMirror site) { |
1165 |
| - Name length = Names.instance(at.getContext()).length; |
1166 |
| - Type intType = Symtab.instance(at.getContext()).intType; |
1167 |
| - |
1168 |
| - return new VarSymbol(Flags.PUBLIC | Flags.FINAL, length, intType, ((Type) site).tsym); |
| 1166 | + private List<Element> createArraySymbols(AnalyzeTask at, TypeMirror site) { |
| 1167 | + Symtab syms = Symtab.instance(at.getContext()); |
| 1168 | + Names names = Names.instance(at.getContext()); |
| 1169 | + Name length = names.length; |
| 1170 | + Name clone = names.clone; |
| 1171 | + Type lengthType = syms.intType; |
| 1172 | + Type cloneType = new MethodType(com.sun.tools.javac.util.List.<Type>nil(), |
| 1173 | + (Type) site, |
| 1174 | + com.sun.tools.javac.util.List.<Type>nil(), |
| 1175 | + syms.methodClass); |
| 1176 | + |
| 1177 | + return List.of( |
| 1178 | + new VarSymbol(Flags.PUBLIC | Flags.FINAL, length, lengthType, ((Type) site).tsym), |
| 1179 | + new MethodSymbol(Flags.PUBLIC | Flags.FINAL, clone, cloneType, ((Type) site).tsym) |
| 1180 | + ); |
1169 | 1181 | }
|
1170 | 1182 |
|
1171 | 1183 | private Element createDotClassSymbol(AnalyzeTask at, TypeMirror site) {
|
|
0 commit comments