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 3933564
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:36:55+00:00 2026-05-19T23:36:55+00:00

There are several other SO questions talking about generics compiling OK w/ Eclipse’s compiler

  • 0

There are several other SO questions talking about generics compiling OK w/ Eclipse’s compiler but not javac (i.e. Java: Generics handled differenlty in Eclipse and javac and Generics compiles and runs in Eclipse, but doesn't compile in javac) — however this looks like a slightly different one.

I have an enum class:

public class LogEvent {
   public enum Type {
       // ... values here ...
   }
   ...
}

and I have another class with a method that takes in arbitrary objects of types descended from Enum:

@Override public <E extends Enum<E>> void postEvent(
    Context context, E code, Object additionalData) 
{
    if (code instanceof LogEvent.Type)
    {
        LogEvent.Type scode = (LogEvent.Type)code;
    ...

This works fine in Eclipse, but when I do a clean built with ant, I am getting a pair of errors, one on the instanceof line, the other on the casting line:

443: inconvertible types
    [javac] found   : E
    [javac] required: mypackage.LogEvent.Type
    [javac]         if (code instanceof LogEvent.Type)
    [javac]             ^

445: inconvertible types
    [javac] found   : E
    [javac] required: com.dekaresearch.tools.espdf.LogEvent.Type
    [javac]             LogEvent.Type scode = (LogEvent.Type)code;
    [javac]                                                  ^

Why does this happen, and how can I get around this problem so it will compile properly?

  • 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-19T23:36:55+00:00Added an answer on May 19, 2026 at 11:36 pm

    I don’t know why it’s happening, but a workaround is easy:

    @Override public <E extends Enum<E>> void postEvent(
        Context context, E code, Object additionalData) 
    {
        Object tmp = code;
        if (tmp instanceof LogEvent.Type)
        {
            LogEvent.Type scode = (LogEvent.Type)tmp;
        ...
    

    It’s ugly, but it works…

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

Sidebar

Related Questions

There are several topics about what questions will be raised in an interview for
There are several ways to do this, but I'm not sure which one of
Several questions about accessor methods in C++ have been asked on SO, but none
There are several people about (myself being one of them) who have been developing
I'm not talking about making portable code. This is more a question of distribution.
I have several questions about the PE subsystem field, which may overlap to some
(I see several questions related to my problem but none of the solutions work
There are several types of objects in a system, and each has it's own
There are several ways to iterate over a result set. What are the tradeoff
There are several plugin options for building a search engine into your Ruby on

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.