comparison truffle/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java @ 22123:329fe954f6f2

Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 02 Sep 2015 13:15:51 +0200
parents 9c8c0937da41
children dc83cc1f94f2
comparison
equal deleted inserted replaced
22122:ac017ff52c07 22123:329fe954f6f2
154 } 154 }
155 final Object[] sortedFields = (Object[]) method(binaryType, "getFields"); 155 final Object[] sortedFields = (Object[]) method(binaryType, "getFields");
156 if (sortedFields != null) { 156 if (sortedFields != null) {
157 sortedElements.addAll(Arrays.asList(sortedFields)); 157 sortedElements.addAll(Arrays.asList(sortedFields));
158 } 158 }
159 final Object[] sortedTypes = (Object[]) method(binaryType, "getMemberTypes", new Class[0]); 159 final Object[] sortedTypes = (Object[]) method(binaryType, "getMemberTypes", new Class<?>[0]);
160 if (sortedTypes != null) { 160 if (sortedTypes != null) {
161 sortedElements.addAll(Arrays.asList(sortedTypes)); 161 sortedElements.addAll(Arrays.asList(sortedTypes));
162 } 162 }
163 163
164 Collections.sort(sortedElements, new Comparator<Object>() { 164 Collections.sort(sortedElements, new Comparator<Object>() {
180 List<Object> bindings = new ArrayList<>(); 180 List<Object> bindings = new ArrayList<>();
181 for (Object sortedElement : sortedElements) { 181 for (Object sortedElement : sortedElements) {
182 Class<?> elementClass = sortedElement.getClass(); 182 Class<?> elementClass = sortedElement.getClass();
183 if (binaryMethod.isAssignableFrom(elementClass)) { 183 if (binaryMethod.isAssignableFrom(elementClass)) {
184 char[] selector = (char[]) method(sortedElement, "getSelector"); 184 char[] selector = (char[]) method(sortedElement, "getSelector");
185 Object[] foundBindings = (Object[]) method(binding, "getMethods", new Class[]{char[].class}, selector); 185 Object[] foundBindings = (Object[]) method(binding, "getMethods", new Class<?>[]{char[].class}, selector);
186 if (foundBindings == null || foundBindings.length == 0) { 186 if (foundBindings == null || foundBindings.length == 0) {
187 continue; 187 continue;
188 } else if (foundBindings.length == 1) { 188 } else if (foundBindings.length == 1) {
189 bindings.add(foundBindings[0]); 189 bindings.add(foundBindings[0]);
190 } else { 190 } else {
197 } 197 }
198 } 198 }
199 } 199 }
200 } else if (binaryField.isAssignableFrom(elementClass)) { 200 } else if (binaryField.isAssignableFrom(elementClass)) {
201 char[] selector = (char[]) method(sortedElement, "getName"); 201 char[] selector = (char[]) method(sortedElement, "getName");
202 Object foundField = method(binding, "getField", new Class[]{char[].class, boolean.class}, selector, true); 202 Object foundField = method(binding, "getField", new Class<?>[]{char[].class, boolean.class}, selector, true);
203 if (foundField != null) { 203 if (foundField != null) {
204 bindings.add(foundField); 204 bindings.add(foundField);
205 } 205 }
206 } else if (nestedType.isAssignableFrom(elementClass)) { 206 } else if (nestedType.isAssignableFrom(elementClass)) {
207 char[] selector = (char[]) method(sortedElement, "getSourceName"); 207 char[] selector = (char[]) method(sortedElement, "getSourceName");
208 Object foundType = method(binding, "getMemberType", new Class[]{char[].class}, selector); 208 Object foundType = method(binding, "getMemberType", new Class<?>[]{char[].class}, selector);
209 if (foundType != null) { 209 if (foundType != null) {
210 bindings.add(foundType); 210 bindings.add(foundType);
211 } 211 }
212 } else { 212 } else {
213 throw new AssertionError("Unexpected encountered type " + elementClass); 213 throw new AssertionError("Unexpected encountered type " + elementClass);
219 219
220 private static Object lookupBinaryType(Object binding) throws Exception { 220 private static Object lookupBinaryType(Object binding) throws Exception {
221 Object lookupEnvironment = field(binding, "environment"); 221 Object lookupEnvironment = field(binding, "environment");
222 Object compoundClassName = field(binding, "compoundName"); 222 Object compoundClassName = field(binding, "compoundName");
223 Object nameEnvironment = field(lookupEnvironment, "nameEnvironment"); 223 Object nameEnvironment = field(lookupEnvironment, "nameEnvironment");
224 Object nameEnvironmentAnswer = method(nameEnvironment, "findType", new Class[]{char[][].class}, compoundClassName); 224 Object nameEnvironmentAnswer = method(nameEnvironment, "findType", new Class<?>[]{char[][].class}, compoundClassName);
225 Object binaryType = method(nameEnvironmentAnswer, "getBinaryType", new Class[0]); 225 Object binaryType = method(nameEnvironmentAnswer, "getBinaryType", new Class<?>[0]);
226 return binaryType; 226 return binaryType;
227 } 227 }
228 228
229 private static List<Object> findSourceTypeOrder(Object binding) throws Exception { 229 private static List<Object> findSourceTypeOrder(Object binding) throws Exception {
230 Object referenceContext = field(field(binding, "scope"), "referenceContext"); 230 Object referenceContext = field(field(binding, "scope"), "referenceContext");