// Use a countdown latch for synchronization, as join() will introduce more roots. final CountDownLatch cdl1 = new CountDownLatch(1);
// Run the follow-references tests on a dedicated thread so we know the specific // Thread type. Thread t = newThread() {
@Override publicvoid run() { try {
Test913.runFollowReferences();
} catch (Exception e) { thrownew RuntimeException(e);
}
cdl1.countDown();
}
};
t.start();
cdl1.await();
doExtensionTests();
}
publicstaticvoid runFollowReferences() throws Exception { new TestConfig().doFollowReferencesTest();
publicstaticvoid doStringTest() throws Exception { final String str = new String("HelloWorld"); final String str2 = new String("");
Object o = new Object() {
String s = str;
String s2 = str2;
};
Object o = new Object() {
Object z = zArray;
Object b = bArray;
Object c = cArray;
Object s = sArray;
Object i = iArray;
Object f = fArray;
Object l = lArray;
Object d = dArray;
};
if (!correctHeapValue)
System.out.println("Heap Trace for Inf2 is not as expected:\n" + heapTrace);
System.out.println(getTag(Inf2.class));
setTag(Inf2.class, 0);
}
privatestaticvoid printStats() {
System.out.println("---"); int s = getGcStarts(); int f = getGcFinishes();
System.out.println((s > 0) + " " + (f > 0));
}
privatestaticboolean hasImage() { try { int pid = Integer.parseInt(new File("/proc/self").getCanonicalFile().getName());
BufferedReader reader = new BufferedReader(new FileReader("/proc/" + pid + "/maps"));
String line; while ((line = reader.readLine()) != null) { // On host the mappings end with .art and on device they end with .art] if (line.endsWith(".art]") || line.endsWith(".art")) {
reader.close(); returntrue;
}
}
reader.close(); returnfalse;
} catch (Exception e) { thrownew RuntimeException(e);
}
}
// Force GCs to clean up dirt.
Runtime.getRuntime().gc();
Runtime.getRuntime().gc();
doFollowReferencesTestRoot();
// Force GCs to clean up dirt.
Runtime.getRuntime().gc();
Runtime.getRuntime().gc();
}
privatevoid doFollowReferencesTestNonRoot(ArrayList<Object> tmpStorage) {
Verifier v = new Verifier();
tagClasses(v);
A a = createTree(v);
tmpStorage.add(a);
v.add("0@0", "1@1000"); // tmpStorage[0] --(array-element)--> a.
publicstaticclass C extends B implements I2 { public A baz; public A baz2; public A[] array;
public C() {} public C(A a, A b) {
baz = a;
baz2 = b;
}
}
privatestaticinterface Inf1 { publicfinalstaticint A = 1;
}
privatestaticinterface Inf2 extends Inf1 { publicfinalstaticint B = 1;
}
privatestaticclass IntObject implements Inf1 { byte b = (byte)1; char c= 'a'; short s = (short)2; int i = 3; long l = 4;
Object o = new Object(); staticint sI = 5;
}
privatestaticclass FloatObject extends IntObject implements Inf2 { float f = 1.23f; double d = 1.23;
Object p = new Object(); staticint sI = 6;
}
publicstaticclass Verifier { // Should roots with vreg=-1 be printed? publicfinalstaticboolean PRINT_ROOTS_WITH_UNKNOWN_VREG = false;
publicstaticclass Node { public String referrer;
public HashSet<String> referrees = new HashSet<>();
publicvoid add(String referrer, String referree) { if (!nodes.containsKey(referrer)) {
nodes.put(referrer, new Node(referrer));
} if (referree != null) {
nodes.get(referrer).referrees.add(referree);
}
}
publicvoid process(String[] lines, String additionalEnabledReferrer, boolean filtered) { // This method isn't optimal. The loops could be merged. However, it's more readable if // the different parts are separated.
ArrayList<String> rootLines = new ArrayList<>();
ArrayList<String> nonRootLines = new ArrayList<>();
// Check for consecutive chunks of referrers. Also ensure roots come first.
{
String currentHead = null; boolean rootsDone = false;
HashSet<String> completedReferrers = new HashSet<>(); for (String l : lines) {
String referrer = getReferrer(l);
if (isRoot(referrer)) { if (rootsDone) {
System.out.println("ERROR: Late root " + l);
print(lines); return;
}
rootLines.add(l); continue;
}
rootsDone = true;
if (currentHead == null) {
currentHead = referrer;
} else { // Ignore 0@0, as it can happen at any time (as it stands for all // other objects). if (!currentHead.equals(referrer) && !referrer.equals("0@0")) {
completedReferrers.add(currentHead);
currentHead = referrer; if (completedReferrers.contains(referrer)) {
System.out.println("Non-contiguous referrer " + l);
print(lines); return;
}
}
}
nonRootLines.add(l);
}
}
// Sort (root order is not specified) and print the roots. // TODO: What about extra roots? JNI and the interpreter seem to introduce those // (though it isn't clear why a debuggable-AoT test doesn't have the same, // at least for locals). For now, swallow duplicates, and resolve once we // have the metadata for the roots.
{
Collections.sort(rootLines);
String lastRoot = null; for (String l : rootLines) { if (lastRoot != null && lastRoot.equals(l)) { continue;
}
lastRoot = l; if (!PRINT_ROOTS_WITH_UNKNOWN_VREG && l.indexOf("vreg=-1") > 0) { continue;
}
System.out.println(l);
}
}
if (filtered) { // If we aren't tracking dependencies, just sort the lines and print. // TODO: As the verifier is currently using the output lines to track dependencies, // we cannot verify that output is correct when parts of it are suppressed by // filters. To correctly track this we need to take node information into // account, and actually analyze the graph.
Collections.sort(nonRootLines); for (String l : nonRootLines) {
System.out.println(l);
}
System.out.println("---"); return;
}
// Iterate through the lines, keeping track of which referrers are visited, to ensure // the order is acceptable.
HashSet<String> enabled = new HashSet<>(); if (additionalEnabledReferrer != null) {
enabled.add(additionalEnabledReferrer);
} // Always add "0@0".
enabled.add("0@0");
for (String l : lines) {
String referrer = getReferrer(l);
String referree = getReferree(l); if (isRoot(referrer)) { // For a root src, just enable the referree.
enabled.add(referree);
} else { // Check that the referrer is enabled (may be visited). if (!enabled.contains(referrer)) {
System.out.println("Referrer " + referrer + " not enabled: " + l);
print(lines); return;
}
enabled.add(referree);
}
}
// Now just sort the non-root lines and output them
Collections.sort(nonRootLines); for (String l : nonRootLines) {
System.out.println(l);
}
privatestatic String getReferrer(String line) { int i = line.indexOf(" --"); if (i <= 0) { thrownew IllegalArgumentException(line);
} int j = line.indexOf(' '); if (i != j) { thrownew IllegalArgumentException(line);
} return line.substring(0, i);
}
privatestatic String getReferree(String line) { int i = line.indexOf("--> "); if (i <= 0) { thrownew IllegalArgumentException(line);
} int j = line.indexOf(' ', i + 4); if (j < 0) { thrownew IllegalArgumentException(line);
} return line.substring(i + 4, j);
}
privatestaticvoid print(String[] lines) { for (String l : lines) {
System.out.println(l);
}
}
}
privatestaticvoid setTag(Object o, long tag) {
Main.setTag(o, tag);
} privatestaticlong getTag(Object o) { return Main.getTag(o);
}
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.14Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-06-29)
¤
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.