[ http://jira.codehaus.org/browse/MNG-2657?page=comments#action_80129 ] 
            
Kenny MacDermid commented on MNG-2657:
--------------------------------------

Actually it appears that this is a difference between eclipse's compiler, and 
sun's. I plan to investigate further, but now believe it it not a bug in maven.

Thank you,

Kenny

> Generics - Compilation failure - incompatible types - cast to parent type 
> from method taking in subtype.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: MNG-2657
>                 URL: http://jira.codehaus.org/browse/MNG-2657
>             Project: Maven 2
>          Issue Type: Bug
>    Affects Versions: 2.0.4
>         Environment: Windows Xp and Ubuntu Linux. Standard x86 hardware.
>            Reporter: Kenny MacDermid
>
> Maven will not compile classes in the following situation, although eclipse 
> will compile them fine:
> These are the two classes that are the types maven is getting confused with:
> public abstract class User {...}
> public class Employee extends User {...}
> A factory called EntityManager returns a generic typed Criteria:
>     public <T, U extends T> Criteria<T> createCriteria(Class<U> c) {
>         return new CriteriaImpl<T>(c);
>     }
> This is being used in the Tests in the following way:
>         Criteria<User> criteria = em.createCriteria(Employee.class);
> As I said, in eclipse this compiles fine, with no warnings. With maven I 
> receive the error message:
> [INFO] Compilation failure
> ...UserTest.java:[59,51] incompatible types
> found   : ....Criteria<....Employee>
> required: ....Criteria<....User>
> The stack trace is as follows:
> org.apache.maven.BuildFailureException: Compilation failure
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:555)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:475)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:454)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
>         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:585)
>         at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>         at 
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation 
> failure
>         at 
> org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:505)
>         at 
> org.apache.maven.plugin.TestCompilerMojo.execute(TestCompilerMojo.java:99)
>         at 
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534)
>         ... 16 more
> Other possible useful maven information (actualy dir replaced with DIR):
> [DEBUG] Configuring mojo 
> 'org.apache.maven.plugins:maven-compiler-plugin:2.0.1:testCompile' -->
> [DEBUG]   (f) basedir = DIR
> [DEBUG]   (f) buildDirectory = DIR\target
> [DEBUG]   (f) classpathElements = [DIR\target\classes, 
> DIR\target\test-classes, ... (many others)]
> [DEBUG]   (f) compileSourceRoots = [DIR\src\test\java]
> [DEBUG]   (f) compilerId = javac
> [DEBUG]   (f) debug = true
> [DEBUG]   (f) fork = false
> [DEBUG]   (f) optimize = false
> [DEBUG]   (f) outputDirectory = DIR\target\test-classes
> [DEBUG]   (f) outputFileName = IdentityRepository-0.1
> [DEBUG]   (f) showDeprecation = false
> [DEBUG]   (f) showWarnings = false
> [DEBUG]   (f) source = 1.5
> [DEBUG]   (f) staleMillis = 0
> [DEBUG]   (f) target = 1.5
> [DEBUG]   (f) verbose = false
> [DEBUG] -- end configuration --
> Thanks in advance,
> Kenny

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to