publicstaticfinal Breakpoint.Manager MANAGER = new Breakpoint.Manager();
// A function we can use as a start breakpoint. publicstaticvoid breakpoint() { return;
}
privatestaticvoid privateBreakpoint() { return;
}
// An interface with a default method we can break on. staticinterface Breakable { publicstaticvoid iBreakpoint() { return;
}
publicdefaultvoid breakit() { return;
}
}
// A class that has a default method we breakpoint on. publicstaticclass TestClass1 implements Breakable { public TestClass1() { super();
} public String toString() { return"TestClass1"; }
}
// A class that overrides a default method that we can breakpoint on and calls super. publicstaticclass TestClass1ext extends TestClass1 { public TestClass1ext() { super();
} public String toString() { return"TestClass1Ext"; } publicvoid breakit() { super.breakit();
}
}
// A class that overrides a default method that we can breakpoint on. publicstaticclass TestClass2 implements Breakable { public String toString() { return"TestClass2"; } publicvoid breakit() { return;
}
}
// A class that overrides a default method that we can breakpoint on and calls super. publicstaticclass TestClass2ext extends TestClass2 { public String toString() { return"TestClass2ext"; } publicvoid breakit() { super.breakit();
}
}
// A class that overrides a default method and calls it directly with interface invoke-super publicstaticclass TestClass3 implements Breakable { public String toString() { return"TestClass3"; } publicvoid breakit() {
Breakable.super.breakit();
}
}
// A class that overrides a default method that we can breakpoint on and calls super to a class // that uses interface-invoke-super. publicstaticclass TestClass3ext extends TestClass3 { public String toString() { return"TestClass3ext"; } publicvoid breakit() { super.breakit();
}
}
publicstaticclass ConstructNative implements Runnable {
Constructor<?> m; Class type; public ConstructNative(Constructor<?> m) { this.m = m; this.type = m.getDeclaringClass();
}
publicstaticvoid runConstructorTests() throws Exception { // The constructors we will be breaking on.
Constructor<?> tc1_construct = TestClass1.class.getConstructor();
Constructor<?> tc1ext_construct = TestClass1ext.class.getConstructor();
Runnable[] tc1_constructors = new Runnable[] { new ConstructNative(tc1_construct), new ConstructReflect(tc1_construct), new ConstructDirect("new TestClass1()", TestClass1::new),
};
Breakpoint.Manager.BP[] tc1_bps = new Breakpoint.Manager.BP[] {
BP(tc1_construct),
};
runTestGroups("TestClass1 constructor", tc1_constructors, tc1_bps);
Runnable[] tc1ext_constructors = new Runnable[] { new ConstructNative(tc1ext_construct), new ConstructReflect(tc1ext_construct), new ConstructDirect("new TestClass1ext()", TestClass1ext::new),
};
Breakpoint.Manager.BP[] tc1ext_bps = new Breakpoint.Manager.BP[] {
BP(tc1_construct), BP(tc1ext_construct),
};
runTestGroups("TestClass1ext constructor", tc1ext_constructors, tc1ext_bps);
}
// These test to make sure we are able to break on functions that might have been quickened or // inlined from the boot-image. These were all chosen for being in the bootclasspath, not being // long enough to prevent inlining, and not being used for the testing framework.
@SuppressWarnings("OptionalOfRedundantMethod") publicstaticvoid runBCPMethodTests(boolean test_BCP_private) throws Exception { // The methods we will be breaking on.
Method bcp_private_method =
test_BCP_private ? Duration.class.getDeclaredMethod("toBigDecimalSeconds") : null;
Method bcp_virtual_method = Optional.class.getDeclaredMethod("isPresent");
Method bcp_static_method = Optional.class.getDeclaredMethod("empty");
Method bcp_private_static_method =
test_BCP_private ? Random.class.getDeclaredMethod("seedUniquifier") : null;
// Some constructors we will break on.
Constructor<?> bcp_stack_constructor = Stack.class.getConstructor();
Constructor<?> bcp_vector_constructor = Vector.class.getConstructor(); if (!(Vector.class.isAssignableFrom(Stack.class))) { thrownew Error("Expected Stack to extend Vector!");
}
// BCP constructors.
Runnable[] vector_constructors = new Runnable[] { new ConstructNative(bcp_vector_constructor), new ConstructReflect(bcp_vector_constructor), new ConstructDirect("new Vector()", Vector::new),
};
Breakpoint.Manager.BP[] vector_breakpoints = new Breakpoint.Manager.BP[] {
BP(bcp_vector_constructor),
};
runTestGroups("Vector constructor", vector_constructors, vector_breakpoints);
Runnable[] stack_constructors = new Runnable[] { new ConstructNative(bcp_stack_constructor), new ConstructReflect(bcp_stack_constructor), new ConstructDirect("new Stack()", Stack::new),
};
Breakpoint.Manager.BP[] stack_breakpoints = new Breakpoint.Manager.BP[] {
BP(bcp_stack_constructor), BP(bcp_vector_constructor),
};
runTestGroups("Stack constructor", stack_constructors, stack_breakpoints);
// Static function
Runnable[] static_invokes = new Runnable[] { new InvokeNativeObject(bcp_static_method, null),
// Static private class function if (test_BCP_private) {
Runnable[] private_static_invokes = new Runnable[] { new InvokeNativeLong(bcp_private_static_method, null),
new InvokeDirect("Random::seedUniquifier", () -> { new Random(); }),
};
Breakpoint.Manager.BP[] private_static_breakpoints = new Breakpoint.Manager.BP[] {
BP(bcp_private_static_method)
};
runTestGroups("bcp private static invoke", private_static_invokes, private_static_breakpoints);
}
// private class method if (test_BCP_private) {
Duration test_duration = Duration.ofDays(14);
Runnable[] private_invokes = new Runnable[] { new InvokeNativeObject(bcp_private_method, test_duration),
// Static class function
Runnable[] static_invokes = new Runnable[] { new InvokeNative(breakpoint_method, null),
new InvokeReflect(breakpoint_method, null),
new InvokeDirect("Test993::breakpoint", Test993::breakpoint),
};
Breakpoint.Manager.BP[] static_breakpoints = new Breakpoint.Manager.BP[] {
BP(breakpoint_method)
};
runTestGroups("static invoke", static_invokes, static_breakpoints);
// Static private class function
Runnable[] private_static_invokes = new Runnable[] { new InvokeNative(private_breakpoint_method, null),
new InvokeDirect("Test993::privateBreakpoint", Test993::privateBreakpoint),
};
Breakpoint.Manager.BP[] private_static_breakpoints = new Breakpoint.Manager.BP[] {
BP(private_breakpoint_method)
};
runTestGroups("private static invoke", private_static_invokes, private_static_breakpoints);
// Static interface function.
Runnable[] i_static_invokes = new Runnable[] { new InvokeNative(i_breakpoint_method, null),
new InvokeReflect(i_breakpoint_method, null),
new InvokeDirect("Breakable::iBreakpoint", Breakable::iBreakpoint),
};
Breakpoint.Manager.BP[] i_static_breakpoints = new Breakpoint.Manager.BP[] {
BP(i_breakpoint_method)
};
runTestGroups("interface static invoke", i_static_invokes, i_static_breakpoints);
// Call default method through a class.
Runnable[] tc1_invokes = new Runnable[] { new InvokeNative(breakit_method, new TestClass1()),
new InvokeReflect(breakit_method, new TestClass1()),
new InvokeDirect("((Breakable)new TestClass1()).breakit()",
() -> ((Breakable)new TestClass1()).breakit()), new InvokeDirect("new TestClass1().breakit()",
() -> new TestClass1().breakit()),
};
Breakpoint.Manager.BP[] tc1_breakpoints = new Breakpoint.Manager.BP[] {
BP(breakit_method)
};
runTestGroups("TestClass1 invokes", tc1_invokes, tc1_breakpoints);
// Call default method through an override and normal invoke-super
Runnable[] tc1ext_invokes = new Runnable[] { new InvokeNative(breakit_method, new TestClass1ext()), new InvokeNative(breakit_method_tc1ext, new TestClass1ext()),
new InvokeReflect(breakit_method, new TestClass1ext()), new InvokeReflect(breakit_method_tc1ext, new TestClass1ext()),
new InvokeDirect("((Breakable)new TestClass1ext()).breakit()",
() -> ((Breakable)new TestClass1ext()).breakit()), new InvokeDirect("((TestClass1)new TestClass1ext()).breakit()",
() -> ((TestClass1)new TestClass1ext()).breakit()), new InvokeDirect("new TestClass1ext().breakit()",
() -> new TestClass1ext().breakit()),
};
Breakpoint.Manager.BP[] tc1ext_breakpoints = new Breakpoint.Manager.BP[] {
BP(breakit_method), BP(breakit_method_tc1ext)
};
runTestGroups("TestClass1ext invokes", tc1ext_invokes, tc1ext_breakpoints);
// Override default/interface method.
Runnable[] tc2_invokes = new Runnable[] { new InvokeNative(breakit_method, new TestClass2()), new InvokeNative(breakit_method_tc2, new TestClass2()),
new InvokeReflect(breakit_method, new TestClass2()), new InvokeReflect(breakit_method_tc2, new TestClass2()),
new InvokeDirect("((Breakable)new TestClass2()).breakit()",
() -> ((Breakable)new TestClass2()).breakit()), new InvokeDirect("new TestClass2().breakit()",
() -> new TestClass2().breakit()),
};
Breakpoint.Manager.BP[] tc2_breakpoints = new Breakpoint.Manager.BP[] {
BP(breakit_method), BP(breakit_method_tc2)
};
runTestGroups("TestClass2 invokes", tc2_invokes, tc2_breakpoints);
// Call overridden method using invoke-super
Runnable[] tc2ext_invokes = new Runnable[] { new InvokeNative(breakit_method, new TestClass2ext()), new InvokeNative(breakit_method_tc2, new TestClass2ext()), new InvokeNative(breakit_method_tc2ext, new TestClass2ext()),
new InvokeReflect(breakit_method, new TestClass2ext()), new InvokeReflect(breakit_method_tc2, new TestClass2ext()), new InvokeReflect(breakit_method_tc2ext, new TestClass2ext()),
new InvokeDirect("((Breakable)new TestClass2ext()).breakit()",
() -> ((Breakable)new TestClass2ext()).breakit()), new InvokeDirect("((TestClass2)new TestClass2ext()).breakit()",
() -> ((TestClass2)new TestClass2ext()).breakit()), new InvokeDirect("new TestClass2ext().breakit())",
() -> new TestClass2ext().breakit()),
};
Breakpoint.Manager.BP[] tc2ext_breakpoints = new Breakpoint.Manager.BP[] {
BP(breakit_method), BP(breakit_method_tc2), BP(breakit_method_tc2ext)
};
runTestGroups("TestClass2ext invokes", tc2ext_invokes, tc2ext_breakpoints);
// Override default method and call it using interface-invoke-super
Runnable[] tc3_invokes = new Runnable[] { new InvokeNative(breakit_method, new TestClass3()), new InvokeNative(breakit_method_tc3, new TestClass3()),
new InvokeReflect(breakit_method, new TestClass3()), new InvokeReflect(breakit_method_tc3, new TestClass3()),
new InvokeDirect("((Breakable)new TestClass3()).breakit()",
() -> ((Breakable)new TestClass3()).breakit()), new InvokeDirect("new TestClass3().breakit())",
() -> new TestClass3().breakit()),
};
Breakpoint.Manager.BP[] tc3_breakpoints = new Breakpoint.Manager.BP[] {
BP(breakit_method), BP(breakit_method_tc3)
};
runTestGroups("TestClass3 invokes", tc3_invokes, tc3_breakpoints);
// Call overridden method using invoke-super
Runnable[] tc3ext_invokes = new Runnable[] { new InvokeNative(breakit_method, new TestClass3ext()), new InvokeNative(breakit_method_tc3, new TestClass3ext()), new InvokeNative(breakit_method_tc3ext, new TestClass3ext()),
new InvokeReflect(breakit_method, new TestClass3ext()), new InvokeReflect(breakit_method_tc3, new TestClass3ext()), new InvokeReflect(breakit_method_tc3ext, new TestClass3ext()),
new InvokeDirect("((Breakable)new TestClass3ext()).breakit()",
() -> ((Breakable)new TestClass3ext()).breakit()), new InvokeDirect("((TestClass3)new TestClass3ext()).breakit()",
() -> ((TestClass3)new TestClass3ext()).breakit()), new InvokeDirect("new TestClass3ext().breakit())",
() -> new TestClass3ext().breakit()),
};
Breakpoint.Manager.BP[] tc3ext_breakpoints = new Breakpoint.Manager.BP[] {
BP(breakit_method), BP(breakit_method_tc3), BP(breakit_method_tc3ext)
};
runTestGroups("TestClass3ext invokes", tc3ext_invokes, tc3ext_breakpoints);
// private instance method.
Runnable[] private_instance_invokes = new Runnable[] { new InvokeNative(private_method, new TestClass4()),
new InvokeDirect("new TestClass4().callPrivateMethod()",
() -> new TestClass4().callPrivateMethod()),
};
Breakpoint.Manager.BP[] private_instance_breakpoints = new Breakpoint.Manager.BP[] {
BP(private_method)
};
runTestGroups( "private instance invoke", private_instance_invokes, private_instance_breakpoints);
}
privatestaticvoid runTestGroups(String name,
Runnable[] invokes,
Breakpoint.Manager.BP[] breakpoints) throws Exception {
System.out.println("Running " + name); for (List<Breakpoint.Manager.BP> bps : allCombinations(Arrays.asList(breakpoints))) {
System.out.println("\tBreaking on " + bps); for (Runnable test : invokes) {
MANAGER.clearAllBreakpoints();
MANAGER.setBreakpoints(bps.toArray(new Breakpoint.Manager.BP[0]));
test.run();
}
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.3 Sekunden
(vorverarbeitet am 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.