Summary: | Exception when trying to evaluate in Snippet Editor | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Samantha Chan <chanskw> |
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P2 | ||
Version: | 3.1 | ||
Target Milestone: | 3.1 RC1 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Samantha Chan
2005-03-30 13:10:38 EST
I think this may be due to the fact that the snippet support jar is compiled against 1.4, and is running on 1.5 (however, I thought a 1.5 VM would run 1.4 files...). This simpler snippet also causes the problem: Collection<String> c = new ArrayList<String>(); c.add("a"); c.add("b"); c.add("c"); Iterator<String> i = c.iterator(); while (i.hasNext()) { System.out.println(i.next()); } If I remove the <String> qualifier from Iterator, then it works. Moving to JCORE for investigation. It looks like the problem is coming from the classfile generated by the IEvaluationContext. The scrapbook page is created in a Java project with 1.5 compilation options. Reproduced. I am investigating. The code generated for the code snippet missed a checkcast. 0 new java/util/ArrayList [19] 3 dup 4 invokespecial java/util/ArrayList.<init>()V [20] 7 astore_1 [c] 8 aload_1 [c] 9 ldc <String "a"> [22] 11 invokeinterface java/util/Collection.add(Ljava/lang/Object;)Z [28] [nargs: 2] 16 pop 17 aload_1 [c] 18 ldc <String "b"> [30] 20 invokeinterface java/util/Collection.add(Ljava/lang/Object;)Z [28] [nargs: 2] 25 pop 26 aload_1 [c] 27 ldc <String "c"> [32] 29 invokeinterface java/util/Collection.add(Ljava/lang/Object;)Z [28] [nargs: 2] 34 pop 35 aload_1 [c] 36 invokeinterface java/util/Collection.iterator()Ljava/util/Iterator; [36] [nargs: 1] 41 astore_2 [i] 42 goto 57 45 getstatic java/lang/System.out Ljava/io/PrintStream; [42] 48 aload_2 [i] 49 invokeinterface java/util/Iterator.next()Ljava/lang/Object; [48] [nargs: 1] // CHECKCAST NEEDED HERE TO CONVERT TO A STRING 54 invokevirtual java/io/PrintStream.println(Ljava/lang/String;)V [54] 57 aload_2 [i] 58 invokeinterface java/util/Iterator.hasNext()Z [58] [nargs: 1] 63 ifne 45 66 return I will investigate why the checkcast is missing. Update CodeSnippetMessageSend. Fixed and released in HEAD. Regression test added in org.eclipse.jdt.core.tests.eval.CodeSnippetTest.testFor89632 Verified for 3.1 RC1 with build I20050527-0010. |