Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4323740
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:02:29+00:00 2026-05-21T09:02:29+00:00

I have a code like this: protected <T> T doSomething(String someParam, Class<T> clazz) {

  • 0

I have a code like this:

protected <T> T doSomething(String someParam, Class<T> clazz) {
...
}

which I use in a TestCase class:

Class clazz = MyClass.class;
MyClass MyClass = someObject.doSomething(someString, clazz);

This code gives a warning in eclipse:

Class is a raw type. References to generic type Class should be parameterized

and

Multiple markers at this line
– Type safety: Unchecked invocation doSomething(String, Class) of the generic method doSomething(String, Class) of type MyClass
– Type safety: The expression of type Class needs unchecked conversion to conform to Class

When I run this code (test) in eclipse – everything works perfectly. When I do it through “mvn clean install” through command prompt, I get:

C:\pathToProject\src\test\java\packagesPath\MyTestCase.java:[xx,xxx] incompatible types found :
java.lang.Object
required: com.somePackagePath.MyClass

But when providing:

Class<MyClass> clazz = MyClass.class;
MyClass MyClass = someObject.doSomething(someString, clazz);

I don’t get any errors nor warnings. .
I understand that java compiler erases type info, so:
Shouldn’t eclipse provide a compiler error instead of warning, or is it the maven-plugin-compiler that creates the problem?
The maven plugin is:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <showDeprecation>false</showDeprecation>
                <debug>true</debug>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>

Kind Regards,
Despot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:02:30+00:00Added an answer on May 21, 2026 at 9:02 am

    This is a known bug in Eclipse: 333011: [compiler][1.5] Eclipse compiles codes which javac rejects: incompatible types . Feel free to vote for the bug and add your use case to it.


    There are situations when javac and Eclipse disagree, and you should report them as bugs. It is preferred to have a standalone test case of as few Java files as possible which can be copy/pasted in Eclipse and compiled using javac from the command line without any dependencies.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code like this: string uriString = @C:\Temp\test.html; Uri uri = new Uri(uriString);
Suppose I have code like this: template<class T, T initial_t> class Bar { //
I have code that looks like this: public class Polynomial { List<Term> term =
i have a code like this, but giving error can not access protected member.
I have some code which must be thread safe whose behavior resembles this: protected
I have code like this: var newMsg = new Msg { Var1 = var1,
I have code like this: template <typename T, typename U> struct MyStruct { T
I have code like this to move the player in my game left, right,
I have code like this var MyObj = { f1 : function(o){ o.onmousedown =
I have code like this: ... entry.KeyPressEvent += EntryKeyPressEvent; ... } void EntryKeyPressEvent(object o,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.