[antlr-interest] Using Antlr v3 with JDK 1.4

Martijn Reuvers martijn.reuvers at gmail.com
Tue Sep 1 11:25:33 PDT 2009


This works for maven to compile with JDK 1.4, unfortunately you must
set the jdk property so it will really compile with that JDK (or it
will use the default jdk of your environment), fork is a must as well.
You could also change the JAVA_HOME setting of your environment to
point to the proper JDK version, then your maven build does not need
to change (1.4 for source / target will be enough then).

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.4</source>
          <target>1.4</target>
          <fork>true</fork>
          <executable>${JAVA_HOME_1_4}/bin/javac</executable>
          <compilerVersion>1.4</compilerVersion>
        </configuration>
      </plugin>

On Tue, Sep 1, 2009 at 7:38 PM, Terence Parr<parrt at cs.usfca.edu> wrote:
> i think that this got messed up when we went to mvn. i wasn't able to
> set source to 1.5 and target to 1.4 i think.
> Ter
> On Sep 1, 2009, at 7:53 AM, Gordon Tyler wrote:
>
>> So I edited the pom.xml for the Java Runtime module to set it to
>> source and target 1.4, tried compiling and it complained about a few
>> generics being used. I edited the source to remove the generics
>> because they weren't really being used (e.g. FastQueue<T> was being
>> used by CommonTokenStream as FastQueue<Object>). Now it compiles
>> successfully.
>>
>> Testing my parser...
>>
>> -----Original Message-----
>> From: Martijn Reuvers [mailto:martijn.reuvers at gmail.com]
>> Sent: September 1, 2009 9:26 AM
>> To: Gordon Tyler
>> Cc: Terence Parr; Jim Idle; antlr-interest at antlr.org
>> Subject: Re: [antlr-interest] Using Antlr v3 with JDK 1.4
>>
>> I have a project at work which must compile against 1.4 too, but the
>> IDE runs with 1.5. To prevent using the 1.5 API's I usually change the
>> JAVA_HOME and PATH before release and set both to use a jdk 1.4
>> specific one (ant is used for that project). In maven just change the
>> version of the compiler to 1.4. In either case it is really compiled
>> against 1.4 and usage of 1.5 specifics is then easily pointed out.
>>
>>
>> On Tue, Sep 1, 2009 at 3:20 PM, Gordon Tyler<Gordon.Tyler at quest.com>
>> wrote:
>>> You can use -target 1.4 and -source 1.4 with the JDK 1.5 compiler
>>> to make it produce 1.4 compatible class files. The remaining
>>> problem is that you're still compiling against the JDK 1.5 runtime
>>> library and you have to be careful not to use 1.5-specific APIs.
>>>
>>> -----Original Message-----
>>> From: Terence Parr [mailto:parrt at cs.usfca.edu]
>>> Sent: August 31, 2009 8:48 PM
>>> To: Jim Idle
>>> Cc: antlr-interest at antlr.org; Gordon Tyler
>>> Subject: Re: [antlr-interest] Using Antlr v3 with JDK 1.4
>>>
>>> cool. see you at the conference. I'm pretty sure I used to run -
>>> target
>>> jsr14 on the releases I made earlier. Neil Gafter, the javac guy,
>>> told
>>> me it works
>>>
>>> Ter
>>>
>>> On Aug 31, 2009, at 5:34 PM, Jim Idle wrote:
>>>
>>>> Pretty sure we can't even though genetics are eluded at the byte
>>>> code
>>>> level. I will look at this definitively next week and we can decide
>>>> what to do at the JVM language conference.
>>>>
>>>> Jim
>>>>
>>>> On Aug 31, 2009, at 7:14 PM, Terence Parr <parrt at cs.usfca.edu>
>>>> wrote:
>>>>
>>>>> Hi. can we do 1.5 javac with -target jsr14?
>>>>> Ter
>>>>> On Aug 31, 2009, at 3:30 PM, Gordon Tyler wrote:
>>>>>
>>>>>> Thanks Steve, and Jim Idle who replied off-list. I guess I'll have
>>>>>> to stick to Antlr v2 until my project drops the JDK 1.4
>>>>>> requirement.
>>>>>> Messing around with retro-weaver sounds dubious and I need to
>>>>>> restrict my third-party dependencies.
>>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Steve Ebersole [mailto:steven.ebersole at gmail.com] On
>>>>>> Behalf Of
>>>>>> Steve Ebersole
>>>>>> Sent: August 31, 2009 6:26 PM
>>>>>> To: Gordon Tyler
>>>>>> Cc: antlr-interest at antlr.org
>>>>>> Subject: Re: [antlr-interest] Using Antlr v3 with JDK 1.4
>>>>>>
>>>>>> I ran into the same issue when first looking at Antlr3.  I was
>>>>>> told
>>>>>> the
>>>>>> intention was to not have the Antlr runtime rely on JDK 1.5; but
>>>>>> unfortunately some JDK 1.5 features ended up getting exposed.
>>>>>>
>>>>>> The outcome of my queries, iirc, was that it would just remain JDK
>>>>>> 1.5
>>>>>> compatible.  You could probably use a retro-weaver though to
>>>>>> make it
>>>>>> 1.4
>>>>>> compatible.  Did not try...
>>>>>>
>>>>>>
>>>>>> On Mon, 2009-08-31 at 14:25 -0700, Gordon Tyler wrote:
>>>>>>> Is it possible to use the Antlr v3 runtime with JDK 1.4? I'm get
>>>>>>> ting
>>>>>>> this error when compiling generated parser code using JDK 1.4,
>>>>>>> which
>>>>>>> indicates that the runtime is compiled with JDK 1.5:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> NewTransformLexer.java:11: cannot access org.antlr.runtime.Lexer
>>>>>>>
>>>>>>> bad class file: lib
>>>>>>> \antlr-runtime-3.1.3.jar(org/antlr/runtime/Lexer.class)
>>>>>>>
>>>>>>> class file has wrong version 49.0, should be 48.0
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Is it just a matter of a recompile of the runtime or does the
>>>>>>> runtime
>>>>>>> use Java 5 features?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Gordon
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ---
>>>>>>>
>>>>>>> Gordon Tyler (Software Developer)
>>>>>>>
>>>>>>> Quest Software <http://www.quest.com/>
>>>>>>>
>>>>>>> 260 King Street East, Toronto, Ontario M5A 4L5, Canada
>>>>>>>
>>>>>>> Voice: (416) 933-5046 | Fax: (416) 933-5001
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>>>>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>>>>> --
>>>>>> Steve Ebersole <steve at hibernate.org>
>>>>>> Hibernate.org
>>>>>>
>>>>>>
>>>>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>>>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>>>>
>>>>>
>>>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>>>
>>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>>
>>>
>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>>
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list