< prev index next >

test/langtools/tools/javac/processing/model/completionfailure/NoAbortForBadClassFile.java

Print this page

196 
197         task.getElements().getTypeElement("java.lang.Object");
198 
199         if (!badClassFile) {
200             //to ensure the same paths taken in ClassFinder.completeEnclosing in case the file is missing:
201             syms.enterClass(syms.unnamedModule, names.fromString(flatName(missing)));
202         }
203 
204         List<String> result = new ArrayList<>();
205 
206         for (Path toCheck : order) {
207             ClassSymbol sym = syms.enterClass(syms.unnamedModule, names.fromString(flatName(toCheck)));
208 
209             try {
210                 sym.complete();
211             } catch (CompletionFailure ignore) {
212             }
213 
214             long flags = sym.flags_field;
215 
216             flags &= ~(Flags.CLASS_SEEN | Flags.SOURCE_SEEN);
217 
218             result.add("sym: " + sym.flatname + ", " + sym.owner.flatName() +
219                        ", " + sym.type + ", " + sym.members_field + ", " + flags);
220         }
221 
222         return result;
223     }
224 
225     private String flatName(Path p) {
226         return p.getFileName().toString().replace(".class", "");
227     }
228 
229     private static class TestClassReader extends ClassReader {
230         public static void preRegister(Context ctx) {
231             ctx.put(classReaderKey, (Factory<ClassReader>) c -> new TestClassReader(ctx));
232         }
233 
234         private final String block;
235 
236         public TestClassReader(Context context) {

196 
197         task.getElements().getTypeElement("java.lang.Object");
198 
199         if (!badClassFile) {
200             //to ensure the same paths taken in ClassFinder.completeEnclosing in case the file is missing:
201             syms.enterClass(syms.unnamedModule, names.fromString(flatName(missing)));
202         }
203 
204         List<String> result = new ArrayList<>();
205 
206         for (Path toCheck : order) {
207             ClassSymbol sym = syms.enterClass(syms.unnamedModule, names.fromString(flatName(toCheck)));
208 
209             try {
210                 sym.complete();
211             } catch (CompletionFailure ignore) {
212             }
213 
214             long flags = sym.flags_field;
215 
216             flags &= ~(Flags.CLASS_SEEN | Flags.SOURCE_SEEN | Flags.IDENTITY_TYPE); // earlier ACC_SUPER was dropped by javac.
217 
218             result.add("sym: " + sym.flatname + ", " + sym.owner.flatName() +
219                        ", " + sym.type + ", " + sym.members_field + ", " + flags);
220         }
221 
222         return result;
223     }
224 
225     private String flatName(Path p) {
226         return p.getFileName().toString().replace(".class", "");
227     }
228 
229     private static class TestClassReader extends ClassReader {
230         public static void preRegister(Context ctx) {
231             ctx.put(classReaderKey, (Factory<ClassReader>) c -> new TestClassReader(ctx));
232         }
233 
234         private final String block;
235 
236         public TestClassReader(Context context) {
< prev index next >