@@ -62,9 +62,9 @@ public GraphAnalysisLoader(ProcessingEnvironment processingEnv) {
62
62
* in canonical class names).
63
63
*/
64
64
@ VisibleForTesting static TypeElement resolveType (Elements elements , String className ) {
65
- int index = nextDollar (className , className , 0 );
65
+ int index = next$ (className , className , 0 );
66
66
if (index == -1 ) {
67
- return elements . getTypeElement (className );
67
+ return getTypeElement (elements , className );
68
68
}
69
69
// have to test various possibilities of replacing '$' with '.' since '.' in a canonical name
70
70
// of a nested type is replaced with '$' in the binary name.
@@ -85,27 +85,27 @@ private static TypeElement resolveType(Elements elements, String className, Stri
85
85
86
86
// We assume '$' should be converted to '.'. So we search for classes with dots first.
87
87
sb .setCharAt (index , '.' );
88
- int nextIndex = nextDollar (className , sb , index + 1 );
88
+ int nextIndex = next$ (className , sb , index + 1 );
89
89
TypeElement type = nextIndex == -1
90
- ? elements . getTypeElement (sb )
90
+ ? getTypeElement (elements , sb )
91
91
: resolveType (elements , className , sb , nextIndex );
92
92
if (type != null ) {
93
93
return type ;
94
94
}
95
95
96
96
// if not found, change back to dollar and search.
97
97
sb .setCharAt (index , '$' );
98
- nextIndex = nextDollar (className , sb , index + 1 );
98
+ nextIndex = next$ (className , sb , index + 1 );
99
99
return nextIndex == -1
100
- ? elements . getTypeElement (sb )
100
+ ? getTypeElement (elements , sb )
101
101
: resolveType (elements , className , sb , nextIndex );
102
102
}
103
103
104
104
/**
105
105
* Finds the next {@code '$'} in a class name which can be changed to a {@code '.'} when computing
106
106
* a canonical class name.
107
107
*/
108
- private static int nextDollar (String className , CharSequence current , int searchStart ) {
108
+ private static int next$ (String className , CharSequence current , int searchStart ) {
109
109
while (true ) {
110
110
int index = className .indexOf ('$' , searchStart );
111
111
if (index == -1 ) {
@@ -122,6 +122,18 @@ private static int nextDollar(String className, CharSequence current, int search
122
122
}
123
123
}
124
124
125
+ private static TypeElement getTypeElement (Elements elements , CharSequence className ) {
126
+ try {
127
+ return elements .getTypeElement (className );
128
+ } catch (ClassCastException e ) {
129
+ // work-around issue in javac in Java 7 where querying for non-existent type can
130
+ // throw a ClassCastException
131
+ // TODO(jh): refer to Oracle Bug ID if/when one is assigned to bug report
132
+ // (Review ID: JI-9027367)
133
+ return null ;
134
+ }
135
+ }
136
+
125
137
@ Override public <T > ModuleAdapter <T > getModuleAdapter (Class <T > moduleClass ) {
126
138
throw new UnsupportedOperationException ();
127
139
}
0 commit comments