#68 Failure to Take Compiler Compliance Level Into Account


I have an Eclipse project that I must build under Java 1.4. In other words, I need to avoid using Java generics.

Project -> Properties -> Java Compiler -> JDK Compliance -> Compiler Compliance Level: 1.4

I have Class A and Class B. When I create a relationship where Class A has-a (Composition) Class B, and I set the cardinality to *, Green generates List<Class B> class B inside of Class A.

Eclipse complains, saying "Syntax error, parameterized types are only available if source level is 5.0" Eclipse recommends that I change my compiler compliance level to 5.0, but what I really need to do is use a data type that is not generic so that I can compile under Java 1.4.

I filed this as a bug, rather than a feature request, since I did not expect Green to generate code that cannot compile, given my project settings.


  • Carl Alphonce

    Carl Alphonce - 2007-10-11

    Logged In: YES
    Originator: NO

    You are right - this is a problem. We will put this on our to-do list for the next release.

    Gene/Brian: more technically, this is not a problem with Green but with the semantics of the relationships. We need to make sure that relationships semantics are written to take this setting into account.

  • Carl Alphonce

    Carl Alphonce - 2007-10-11
    • assigned_to: nobody --> zgwang
  • Anonymous - 2008-01-23

    Logged In: YES
    Originator: NO

    This brings up an interesting issue: Won't a non-generic relationship A *-> B have a declared type of List and an actual type of ArrayList? How are you going to express B as the target type, considering that there may be any number of instances of B (or B's parent, or B's children) inserting into the list?

    The problem I'm seeing is that with the recognizer, the relationship will be recognized A -> List instead of A -> B. Annotations aren't available in 1.4... I'm not really sure what to recommend here.

    There might be a way to set the compiler level compliance in the CompilationUnit class so that 1.4 code is generated. We have code somewhere in Green that allows us to check against system preferences, so finding out what the user has it set to shouldn't be too difficult (note that the Project-level setting might override that value; that's probably where the check should be done).


Log in to post a comment.