Double instrumentation fails
osundblad opened this issue · 3 comments
A small but annoying problem is that if you:
- compile the annotated files with IDEA, then
- without clean compile with maven instrumenter
The java files are correctly not compiled again (since no change) but the instrumenter tries to instrument again and compilation fails.
I cannot reproduce issue now.
@osundblad what version of IDEA do you use?
Could you please create small project that demonstrates problem?
As i can see instrumenter re-instruments already instrument files without any troubles: (phrase looks weird :) )
vlad@unit-421 ~/tmp/test-instrumenter $ mvn process-classes
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test-instrumenter 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ test-instrumenter ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ test-instrumenter ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- notnull-instrumenter-maven-plugin:1.0-SNAPSHOT:instrument (default) @ test-instrumenter ---
[INFO] Added @NotNull assertions to 1 files
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.986s
[INFO] Finished at: Wed Jan 09 16:17:01 MSK 2013
[INFO] Final Memory: 6M/118M
[INFO] ------------------------------------------------------------------------
Also i have found that double instrumentation works and append another checks into .class file:
javap -c target/classes/Main.class
Compiled from "Main.java"
public class Main {
public Main();
Code:
0: aload_0
1: invokespecial #9 // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: aload_0
1: ifnonnull 14
4: new #16 // class java/lang/IllegalArgumentException
7: dup
8: ldc #18 // String Argument 0 for @NotNull parameter of Main.main must not be null
10: invokespecial #21 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
13: athrow
14: aload_0
15: ifnonnull 28
18: new #16 // class java/lang/IllegalArgumentException
21: dup
22: ldc #18 // String Argument 0 for @NotNull parameter of Main.main must not be null
24: invokespecial #21 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
27: athrow
28: aload_0
29: ifnonnull 42
32: new #16 // class java/lang/IllegalArgumentException
35: dup
36: ldc #18 // String Argument 0 for @NotNull parameter of Main.main must not be null
38: invokespecial #21 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
41: athrow
42: getstatic #27 // Field java/lang/System.out:Ljava/io/PrintStream;
45: ldc #29 // String Omnomnom
47: invokevirtual #34 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
50: return
}
I cannot reproduced it now either. So close it. Sorry for the extra work!
PS I still wonder what happened (I have to remember to supply a test case next time) but it felt so obvious since we were a team of five developers that all had this problem when we switched to using this maven plugin (we used a modified version of the electriccloud plugin before). And I got it on my private projects as well.
PPS Thanks for the plugin it is great.