/* * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/ package compiler.cha;
public T receiver(int id) { return receivers.computeIfAbsent(id, (i -> { try {
MyClassLoader cl = (MyClassLoader) receiver.getClassLoader(); Class<?> sub = cl.subclass(receiver, i); return (T)sub.getDeclaredConstructor().newInstance();
} catch (Exception e) { thrownew Error(e);
}
}));
}
publicvoid compile(Runnable r) { while (!WB.isMethodCompiled(TEST)) { for (int i = 0; i < 100; i++) {
r.run();
}
}
assertCompiled(); // record nmethod info
}
private NMethod prevNM = null;
publicvoid assertNotCompiled() {
NMethod curNM = NMethod.get(TEST, false);
assertTrue(prevNM != null); // was previously compiled
assertTrue(curNM == null || prevNM.compile_id != curNM.compile_id); // either no nmethod present or recompiled
prevNM = curNM; // update nmethod info
}
publicvoid assertCompiled() {
NMethod curNM = NMethod.get(TEST, false);
assertTrue(curNM != null); // nmethod is present
assertTrue(prevNM == null || prevNM.compile_id == curNM.compile_id); // no recompilations if nmethod present
prevNM = curNM; // update nmethod info
}
protectedClass<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
{ // First, check if the class has already been loaded Class<?> c = findLoadedClass(name); if (c == null) { try {
c = getParent().loadClass(name); if (name.endsWith("ObjectToStringHelper")) {
ClassWriter cw = new ClassWriter(COMPUTE_MAXS | COMPUTE_FRAMES);
cw.visit(52, ACC_PUBLIC | ACC_SUPER, intl(name), null, "java/lang/Object", null);
byte[] classFile = cw.toByteArray(); return defineClass(name, classFile, 0, classFile.length);
} elseif (c == test || name.startsWith(test.getName())) { try {
String path = name.replace('.', '/') + ".class"; byte[] classFile = getParent().getResourceAsStream(path).readAllBytes(); return defineClass(name, classFile, 0, classFile.length);
} catch (IOException e) { thrownew Error(e);
}
}
} catch (ClassNotFoundException e) { // ClassNotFoundException thrown if class not found // from the non-null parent class loader
}
if (c == null) { // If still not found, then invoke findClass in order // to find the class.
c = findClass(name);
}
} if (resolve) {
resolveClass(c);
} return c;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.