Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapToBean can generate clashing names #1

Closed
bmc opened this issue Sep 29, 2010 · 1 comment
Closed

MapToBean can generate clashing names #1

bmc opened this issue Sep 29, 2010 · 1 comment

Comments

@bmc
Copy link
Owner

bmc commented Sep 29, 2010

MapToBean generates class names by default (though this can be overridden by callers). Its strategy for doing so, however, is flawed. It uses a random number generator to generate a unique class name, but the random number period is too small, leading to potential re-use of names and, ultimately, errors like this:

java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.clapper.classutil.ClassUtil$.loadClass(ClassUtil.scala:149)
    at org.clapper.classutil.asm.MapToBeanMapperImpl.makeBean(MapToBeanMapperImpl.scala:131)
    at org.clapper.classutil.MapToBean$.apply(MapToBean.scala:164)
    at foo$$anonfun$main$1.apply(foo.scala:8)
    at foo$$anonfun$main$1.apply(foo.scala:8)
    at scala.collection.immutable.Range$ByOne$class.foreach(Range.scala:282)
    at scala.collection.immutable.Range$$anon$1.foreach(Range.scala:274)
    at foo$.main(foo.scala:8)
    at foo.main(foo.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:81)
    at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:24)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:86)
    at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:81)
    at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:86)
    at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:83)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Caused by: java.lang.LinkageError: loader (instance of  scala/tools/nsc/util/ScalaClassLoader$URLClassLoader): attempted  duplicate class definition for name: "org/clapper/classutil/MapBean$5743"
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
    ... 23 more

Either widen the range or substitute some other mechanism (e.g., a UUID).

@bmc
Copy link
Owner Author

bmc commented Sep 29, 2010

Fixed in release 0.3.1

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant