facebook

Enum compilation missing switch map

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #621357 Reply

    stefanhermanek
    Participant

    Hello!

    All of a sudden my Eclipse refuses to compile enums with included switch statements correctly.
    Before my class AttributeTypeEnum.java was compiled into two classes, one being AttributeTypeEnum$1.class, now this class is missing and the code won’t run (ClassNotFoundException).

    Compiling the code with javac creates both classes.

    Maybe something with the settings, but the java compiler for the project is set to JDK Complinace 1.8.
    Are there other settings which influence this behaviour?

    Any help is much appreciated!

    Thank you in advance,
    Stefan

    MyEclipse Enterprise Workbench
    Version: 2017 Stable 2.0
    Build id: 15.0.1-20171220

    #621358 Reply

    support-swapna
    Moderator

    Stefan,

    Sorry that you are seeing this problem.

    Can you please give us some more details?

    1. Can you please share with us the full error that you get when the compile fails?
    2. Are you compiling the code with javac outside of MyEclipse from command line? If yes, then which version of Java is being used? You can get the version details by running java -version

    Apologies for inconvenience caused.

    –Swapna
    Genuitec Support

    #621360 Reply

    stefanhermanek
    Participant

    Hi Swapna,

    thanks for the reply!

    ad 1. The compilation process in Eclipse doesn’t give any error, just the mentioned class is not in the output folder.
    ad 2. Yes, the version is 1.8.0_40

    cheers,
    Stefan

    #621535 Reply

    Brian Fernandes
    Moderator

    Stefan,

    We were able to reproduce this as well – Eclipse does not create the $1 class, but javac does. From our research, it looks like javac does for each enum that’s used in switch statement. A similar issue is discussed in this Eclipse bug.

    In our case though, we were able to run the program fine, without having to compile it externally. The program is executed with a regular javaw.exe, not by Eclipse tech, so this (not having the $1 class) is something that clearly works with generic Java. This ultimately seems to be a compiler difference, with both forms being valid.

    1) Could you tell us, exactly how you’re trying to run the program? Since you are also using javac externally, could there be some mixed classes in there (some compiled by javac, others by Eclipse), resulting in the $1 class being required?
    A similar situation is discussed in the above bug.
    2) Were you seeing the $1 classes generated before and it suddenly stopped? It doesn’t look like there is a switch for this behavior, so it should have always been consistent in Eclipse.

    Hope we’ll be able to resolve this soon.

    #621938 Reply

    stefanhermanek
    Participant

    Hello Brian,

    My problem is slightly different than the mentioned bug, because in my case the $1 class is not created in the projcet build directory during compilation.

    ad 1) This is my setup:
    JBoss 6-eap
    JavaEE 5.0

    I use Eclipse during development for compilation, deployment to JBoss and starting the server.
    For production we have an external ant based environment to build the EAR file which uses javac.

    The external build is used seldom and usually the projects are cleaned and build in Eclipse after that.
    When the error showed up I tried the following solutions:
    – clean all projects and rebuild
    – delete the server and create a new one
    – deleted all files in the JBoss standalone\deployments directory

    After ~2 hours of trying all these processes multiple times it worked again but without any hint why.

    ad2) The Eclipse build worked and I never experienced this bug in the last 1-2 years, it appeared suddenly.
    The only change which I remember was this: We keep our JBoss environment in one directory called jboos-6-eap. For every new project in Eclipse it is copied with a new name and new Server runtime is set up in Eclipse. This way each project has its own JBoss environment.
    I added a new project to Eclipse and assigned it new Server runtime pointing to a new jboss-6-eap copy before I experienced this bug.

    Cheers,
    Stefan

    #621939 Reply

    Brian Fernandes
    Moderator

    Stefan,

    Thanks for sending in those details. Just to clarify, wasn’t saying your problem was the same as what is in the bug, only similar. In comment #13 there is a note about the fact that JDT does not generate the anonymous classes (for enums in switches), but javac does.

    After ~2 hours of trying all these processes multiple times it worked again but without any hint why.

    Can you confirm that you now are getting the $1 class generated, and that’s why it’s working? Or is the application working (perhaps without needing this class?)

    It clearly looks like there would be little chance of mixed compilation with the steps you have outlined, especially creating a new server. Not sure if there’s a cache elsewhere that is being missed.

    ad2) The Eclipse build worked and I never experienced this bug in the last 1-2 years, it appeared suddenly.

    Are you sure you were seeing the $1 files generated in the past, or has your code changed recently to now require it? Additionally, no new version of Java, no new version of MyEclipse? No change in compiler compliance? To be best of my knowledge, as I said before, Eclipse would never have generated this class, even in the past (there is not much info on this besides the linked bug), which is why this is confusing.

    Sorry for the basic questions, just trying to ensure we are on the same page.

    #621943 Reply

    stefanhermanek
    Participant

    Hello Brian,

    Can you confirm that you now are getting the $1 class generated, and that’s why it’s working? Or is the application working (perhaps without needing this class?)

    The $1 is not generated in Eclipse and the application is running fine.

    Are you sure you were seeing the $1 files generated in the past…

    I did not look for this class in the past because no errors occurred.

    Additionally, no new version of Java, no new version of MyEclipse? No change in compiler compliance?

    Nope, just the new Server runtime

    I think you are right with you assumptions regarding the mixed compilation and some cache. If you further look into this and find a more consistent way to clean the system please let me know.

    Thank your for the help!
    Stefan

    #622032 Reply

    Brian Fernandes
    Moderator

    Stefan,

    Thank you for getting back to us with the clarifications – it’s good to know you have a running application without the $1 classes.

    I believe the problem is specific to your particular workflow, and we have been unable to reproduce it so far, but we’ll keep an eye out for it nevertheless!

    Thanks!

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: Enum compilation missing switch map

You must be logged in to post in the forum log in