Bug 71612 - [1.5] ClassFormatError when running simple example
Summary: [1.5] ClassFormatError when running simple example
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-07 03:30 EDT by Kasper Nielsen CLA
Modified: 2004-11-04 11:38 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kasper Nielsen CLA 2004-08-07 03:30:01 EDT
public class ErrorTest extends AbstractSet<Runnable>{

    public static void main(String[] args) {
        ErrorTest t=new ErrorTest();
        t.add(null);
    }
    
    public boolean add(Runnable run) {
        System.out.println("success");
        return true;
    }
    public Iterator iterator() {return null;}
    public int size() {return 0;}
}

when tried to execute, fails with:

java.lang.ClassFormatError: Repetitive method name/signature in class file ErrorTest
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:605)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
Comment 1 Olivier Thomann CLA 2004-08-08 17:14:41 EDT
Here is the disassembled output of this .class file:
// Compiled from ErrorTest.java (version 1.5 : 49.0, super bit)
// Signature: Ljava/util/AbstractSet<Ljava/lang/Runnable;>;
public class ErrorTest extends java.util.AbstractSet {
  
  // Method descriptor  #6 ()V
  // Stack: 1, Locals: 1
  public ErrorTest();
    0  aload_0
    1  invokespecial #10 <Method java/util/AbstractSet.<init>()V>
    4  return
      Line numbers:
        [pc: 0, line: 3]
      Local variable table:
        [pc: 0, pc: 5] local: this index: 0 type: LErrorTest;
  
  // Method descriptor  #16 ([Ljava/lang/String;)V
  // Stack: 2, Locals: 2
  public static void main(String[] args);
     0  new #2 ErrorTest
     3  dup
     4  invokespecial #17 <Method ErrorTest.<init>()V>
     7  astore_1
     8  aload_1
     9  aconst_null
    10  invokevirtual #21 <Method ErrorTest.add(Ljava/lang/Runnable;)Z>
    13  pop
    14  return
      Line numbers:
        [pc: 0, line: 6]
        [pc: 8, line: 7]
        [pc: 14, line: 8]
      Local variable table:
        [pc: 0, pc: 15] local: args index: 0 type: [Ljava/lang/String;
        [pc: 8, pc: 15] local: t index: 1 type: LErrorTest;
  
  // Method descriptor  #19 (Ljava/lang/Runnable;)Z
  // Stack: 2, Locals: 2
  public boolean add(Runnable run);
    0  getstatic #30 <Field java/lang/System.out Ljava/io/PrintStream;>
    3  ldc #32 <String "success">
    5  invokevirtual #38 <Method java/io/PrintStream.println(Ljava/lang/String;)V>
    8  iconst_1
    9  ireturn
      Line numbers:
        [pc: 0, line: 11]
        [pc: 8, line: 12]
      Local variable table:
        [pc: 0, pc: 10] local: this index: 0 type: LErrorTest;
        [pc: 0, pc: 10] local: run index: 1 type: Ljava/lang/Runnable;
  
  // Method descriptor  #42 ()Ljava/util/Iterator;
  // Stack: 1, Locals: 1
  public Iterator iterator();
    0  aconst_null
    1  areturn
      Line numbers:
        [pc: 0, line: 14]
      Local variable table:
        [pc: 0, pc: 2] local: this index: 0 type: LErrorTest;
  
  // Method descriptor  #44 ()I
  // Stack: 1, Locals: 1
  public int size();
    0  iconst_0
    1  ireturn
      Line numbers:
        [pc: 0, line: 15]
      Local variable table:
        [pc: 0, pc: 2] local: this index: 0 type: LErrorTest;
  
  // Method descriptor  #45 (Ljava/lang/Object;)Z
  // Stack: 2, Locals: 2
  public bridge synthetic boolean add(Object arg);
    0  aload_0
    1  aload_1
    2  checkcast #47 java/lang/Runnable
    5  invokevirtual #21 <Method ErrorTest.add(Ljava/lang/Runnable;)Z>
    8  ireturn
      Line numbers:
        [pc: 0, line: 1]
  
  // Method descriptor  #45 (Ljava/lang/Object;)Z
  // Stack: 2, Locals: 2
  public bridge synthetic boolean add(Object arg);
    0  aload_0
    1  aload_1
    2  checkcast #47 java/lang/Runnable
    5  invokevirtual #21 <Method ErrorTest.add(Ljava/lang/Runnable;)Z>
    8  ireturn
      Line numbers:
        [pc: 0, line: 1]
}

We can see that the last method is twice in the class file.
Comment 2 Kent Johnson CLA 2004-08-09 08:23:00 EDT
What drop are you running on?
Comment 3 Kasper Nielsen CLA 2004-08-09 08:28:06 EDT
sorry,

Version: 3.1.0
Build id: 200408010010

Comment 4 Kent Johnson CLA 2004-08-09 10:45:49 EDT
Released a temporary fix in Head.

Moving to philippe so we can discuss a better solution when he returns.
Comment 5 Frederic Fusier CLA 2004-11-02 12:42:27 EST
Fixed in HEAD.

Test case added: GenericTypeTest#test379
Comment 6 Frederic Fusier CLA 2004-11-04 11:38:52 EST
Verified for 3.1 M3 with build I200411040800