Skip to content

Commit f33e748

Browse files
Add ability to overlay classes with new definitions of existing methods
Allows multiple definitions of the same class to appear on the classpath, so long as all but the first definition are marked with the attribute @java::com.diffblue.security.OverlayClassImplementation. Overlay class definitions can contain methods with the same signature as methods in the original class, so long as these are marked with the attribute @java::com.diffblue.security.OverlayMethodImplementation; such overlay methods are replaced in the original file with the version found in the last overlay on the classpath. Later definitions can also contain new supporting methods and fields that are merged in. This will allow insertion of Java methods into library classes to handle, for example, modelling dependency injection. Includes regression tests Improvements over earlier version: Allows loading of classes such as java.lang.Object from an explicit model Prevent attempting to load any class more than once Invalid values in the classpath are ignored Handles duplicate files appearing in multiple items on the classpath Filter loaded class files to remove duplicates or misordered overlays before following links to other classes so as not to add dependencies of duplicate classes
1 parent e738f98 commit f33e748

32 files changed

+852
-276
lines changed
228 Bytes
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public class Test {
2+
public void main() {}
3+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE symex-driven-lazy-loading-expected-failure
2+
Test.class
3+
--classpath ./NotHere.jar
4+
^EXIT=6$
5+
^SIGNAL=0$
6+
^the program has no entry point$
7+
^failed to load class `Test'$
8+
--
9+
--
10+
symex-driven lazy loading should emit "the program has no entry point" but currently doesn't
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE symex-driven-lazy-loading-expected-failure
2+
Test.class
3+
--classpath ./NotHere
4+
^EXIT=6$
5+
^SIGNAL=0$
6+
^the program has no entry point$
7+
^failed to load class `Test'$
8+
--
9+
--
10+
symex-driven lazy loading should emit "the program has no entry point" but currently doesn't
583 Bytes
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class Test
2+
{
3+
public int x;
4+
5+
public static void main(String[] args)
6+
{
7+
assert(false);
8+
}
9+
10+
public static void notOverlain()
11+
{
12+
assert(true);
13+
}
14+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.diffblue;
2+
3+
public @interface OverlayClassImplementation {
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.diffblue;
2+
3+
public @interface OverlayMethodImplementation {
4+
}

0 commit comments

Comments
 (0)