fmgasparino / google-gin

Automatically exported from code.google.com/p/google-gin
Apache License 2.0
0 stars 0 forks source link

GinjectorGeneratorImpl.java does not appropriately handle inner class naming. #107

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I was working on a test suite where one test class had defined a static inner 
class called 
TestInjector.  I wrote a new test which defined its own static inner class 
called TestInjector.

When running my individual test, it passed.  When running the whole suite, I 
got a class cast 
exception, due to the GinjectorGeneratorImpl attempting to reuse one inner 
classes's generated 
code in the other inner class.  By renaming the TestInjector classes, this 
error goes away.

Instead of naming these classes com.google.project.TestA$InnerClass and 
com.google.project.TestB$InnerClass, the generator is creating the code to look 
like 
com.google.project.InnerClass.  

The offending line:
String implClassName = ginjectorInterface.getSimpleSourceName() + "Impl";

So by changing getSimpleSourceName() to getName() we'll solve my problem.  Of 
course if 
someone actually named something with the suffix Impl in your package will 
still cause issues 
(and already does cause issues)

Original issue reported on code.google.com by bens...@google.com on 16 May 2010 at 12:21

GoogleCodeExporter commented 9 years ago
Ha, good catch. I'll fix this once the currently pending patches are in.

Original comment by aragos on 16 May 2010 at 3:13

GoogleCodeExporter commented 9 years ago
Fix submitted for review at: http://codereview.appspot.com/1725050

Original comment by aragos on 7 Jul 2010 at 4:11

GoogleCodeExporter commented 9 years ago
Fixed in r142.

Original comment by aragos on 8 Jul 2010 at 10:18