147
148 // double check our class hasn't been loaded yet
149 for (Class clazz : inst.getAllLoadedClasses()) {
150 if (clazz.getName().equals(CLASS_TO_BREAK)) {
151 throw new AssertionError("Oops! Class " + CLASS_TO_BREAK + " is already loaded, the test can't work");
152 }
153 }
154
155 boolean retransform = Boolean.getBoolean("agent.retransform");
156
157 try {
158 if (retransform) {
159 // Retransform the class for the VerifyError.
160 var clazz = Class.forName(CLASS_TO_BREAK);
161 inst.addTransformer(new BadTransformer(), true);
162 inst.retransformClasses(clazz);
163 } else {
164 // Load the class instrumented with CFLH for the VerifyError.
165 inst.addTransformer(new BadTransformer());
166 Class<?> cls = Class.forName(CLASS_TO_BREAK);
167 }
168 throw new RuntimeException("Failed: Did not throw VerifyError");
169 } catch (VerifyError e) {
170 System.out.println("Passed: VerifyError " + e.getMessage());
171 }
172 }
173 }
|
147
148 // double check our class hasn't been loaded yet
149 for (Class clazz : inst.getAllLoadedClasses()) {
150 if (clazz.getName().equals(CLASS_TO_BREAK)) {
151 throw new AssertionError("Oops! Class " + CLASS_TO_BREAK + " is already loaded, the test can't work");
152 }
153 }
154
155 boolean retransform = Boolean.getBoolean("agent.retransform");
156
157 try {
158 if (retransform) {
159 // Retransform the class for the VerifyError.
160 var clazz = Class.forName(CLASS_TO_BREAK);
161 inst.addTransformer(new BadTransformer(), true);
162 inst.retransformClasses(clazz);
163 } else {
164 // Load the class instrumented with CFLH for the VerifyError.
165 inst.addTransformer(new BadTransformer());
166 Class<?> cls = Class.forName(CLASS_TO_BREAK);
167 System.out.println("class loaded" + cls);
168 }
169 throw new RuntimeException("Failed: Did not throw VerifyError");
170 } catch (VerifyError e) {
171 System.out.println("Passed: VerifyError " + e.getMessage());
172 }
173 }
174 }
|