|
23 | 23 | import org.aspectj.bridge.IMessage.Kind; |
24 | 24 | import org.aspectj.bridge.IMessageHandler; |
25 | 25 | import org.aspectj.util.LangUtil; |
| 26 | +import org.aspectj.weaver.TypeFactory; |
26 | 27 | import org.aspectj.weaver.UnresolvedType; |
27 | 28 | import org.aspectj.weaver.bcel.ClassPathManager.ClassFile; |
28 | 29 |
|
@@ -76,7 +77,33 @@ private static File walk(File dir, String jar) { |
76 | 77 | } |
77 | 78 |
|
78 | 79 | public void testInstructions() { |
79 | | - System.out.println("This test is really only for standalone usage as it need executing on multiple JDK levels"); |
| 80 | + System.out.println( |
| 81 | + "This test is mostly for stand-alone usage (rename 'xtest*' to 'test*'), " + |
| 82 | + "as it needs execution on multiple JDK levels" |
| 83 | + ); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * See <a href="https://github.com/eclipse-aspectj/aspectj/issues/306">GitHub issue 306</a> |
| 88 | + */ |
| 89 | + public void testUnfoundClassPerformance() { |
| 90 | + final int ROUNDS = 10_000; |
| 91 | + final int MAX_TIME = 500; |
| 92 | + |
| 93 | + List<String> classPath = Arrays.asList(System.getProperty("java.class.path").split(File.pathSeparator)); |
| 94 | + //System.out.println(classPath); |
| 95 | + ClassPathManager classPathManager = new ClassPathManager(classPath, null); |
| 96 | + UnresolvedType unresolvedType = TypeFactory.createTypeFromSignature("Ljava/lang/String;"); |
| 97 | + |
| 98 | + long startTime = System.currentTimeMillis(); |
| 99 | + for (int i = 0; i < ROUNDS; i++) |
| 100 | + classPathManager.find(unresolvedType); |
| 101 | + long duration = System.currentTimeMillis() - startTime; |
| 102 | + |
| 103 | + assertTrue( |
| 104 | + String.format("Duration for %d rounds should be < %d ms, but was %d ms", ROUNDS, MAX_TIME, duration), |
| 105 | + duration < MAX_TIME |
| 106 | + ); |
80 | 107 | } |
81 | 108 |
|
82 | 109 | public void xtestSanity18accessing18RTJAR() throws IOException { |
|
0 commit comments