#2149 java.lang.ClassFormatError: Duplicate field name&signature

SlimerDude Wed 22 May 2013

Here's an interesting one, the combination of everything below gives a java.lang.ClassFormatError. It hinges on the arg for stuff being called type and passed through the closure, so I suspect it's some naming issue with the code generator.

If you change the method sig to Void stuff(Type type2) then it works fine.

Fan code and stack below:

class ClassBug {
  Void stuff(Type type) {
    stackTraceFilter |->| {
      stuff2(ClassBug#, "$type") 
    }
  }

  Void stackTraceFilter(|->| func) {
    func.call
  }
  
  static Void stuff2(Type log, Str msg) { }

  static Void main(Str[] args) {
    ClassBug().stuff(ClassBug#)
  }
}

java.lang.ClassFormatError: Duplicate field name&signature in class file fan/Wotever/ClassBug$stuff$0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at fan.sys.FanClassLoader.findPendingClass(FanClassLoader.java:130)
	at fan.sys.FanClassLoader.findClass(FanClassLoader.java:88)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at fan.sys.FanClassLoader.loadFan(FanClassLoader.java:57)
	at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:265)
	at fan.sys.Env.loadTypeClasses(Env.java:206)
	at fan.sys.ClassType.emit(ClassType.java:490)
	at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:175)
	at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at java.lang.Class.getDeclaredFields0(Native Method)
	at java.lang.Class.privateGetDeclaredFields(Class.java:2300)
	at java.lang.Class.getDeclaredFields(Class.java:1745)
	at fan.sys.ClassType.finishSlots(ClassType.java:588)
	at fan.sys.ClassType.finish(ClassType.java:550)
	at fan.sys.Method$MethodFunc.isStatic(Method.java:475)
	at fan.sys.Method$MethodFunc.callList(Method.java:191)
	at fan.sys.Method.callList(Method.java:138)
	at fanx.tools.Fan.callMain(Fan.java:173)
	at fanx.tools.Fan.executeType(Fan.java:140)
	at fanx.tools.Fan.execute(Fan.java:41)
	at fanx.tools.Fan.run(Fan.java:298)
	at fanx.tools.Fan.main(Fan.java:336)
sys::Err: Method not mapped to java.lang.reflect correctly Wotever::ClassBug.main
  fan.sys.Method$MethodFunc.isStatic (Method.java:482)
  fan.sys.Method$MethodFunc.callList (Method.java:191)
  fan.sys.Method.callList (Method.java:138)
  fanx.tools.Fan.callMain (Fan.java:173)
  fanx.tools.Fan.executeType (Fan.java:140)
  fanx.tools.Fan.execute (Fan.java:41)
  fanx.tools.Fan.run (Fan.java:298)
  fanx.tools.Fan.main (Fan.java:336)

brian Wed 22 May 2013

Promoted to ticket #2149 and assigned to brian

brian Wed 22 May 2013

Ticket resolved in 1.0.66

Interesting, surprised I've never seen that before. It was a naming collision b/w how we emit type literals and closure variables. changeset

SlimerDude Wed 22 May 2013

It was a scary bug to encounter - all of a sudden (after a benign code change) 120+ tests were failing with a ClassFormatError! Eeek! I thought I had irrecoverably screwed up my environment!

But a swift roll back proved it was just fan code. Phew!

Login or Signup to reply.