Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] iajc compiler failure due to generics

You have to tell iajc to use the java 5 source level. I don't know if it's still true, but the last time I ran into this, there was no way to specify this in the XML, oddly enough!  

Here's what I did.

1) Add the following to the <iajc ...> tag:
     argfiles=".../ajc.args.lst"
Use whatever file name and location you want.

2) Define that file to include the following:
   -1.5

Maybe there is a way to specify this in the XML by now.

dean

On May 1, 2008, at 10:24 AM, John Damask wrote:

Hi
I'm having a common AspectJ compilation problem. A project developed with Eclipse 3.2.2 & AJDT 1.4.2 will compile and run fine when controlled by
the IDE. However, I'd like to build the project via Ant. My build file was constructed using the AJDT help page but I'm getting iajc errors that indicate it's
using JDK 1.4 instead of 1.5, e.g. "Syntax error, parameterized types are only available if source level is 5.0".

The Ant External Tools->JRE is set to JDK1.5.0.11 and I've copied the JRE components of the classpath shown in the AJDT Event Trace window to my Ant script as well as to the Ant->External Tools classpath.

Where else do I need to specify the JDK?

I've attached a simple AspectJ Hello World app build file along with the Ant output

Thanks,
John

===============
build.xml
===============

<project name="test" basedir="." default="build">
       <property file="build.properties"/>
       <property environment="env" />
       <!-- ==================== Init Target ====================================
-->

       <!--

         The "init" target configures the necessary AspectJ components

       -->
       <target name="init">
               <path id="ajde.classpath">
                       <pathelement path="${plugins.dir}/org.eclipse.core.resources_3.2.2.R32x_v20061218.jar" />
                       <pathelement path="${plugins.dir}/org.eclipse.core.runtime.compatibility_3.1.100.v20060603.jar"/>
                       <pathelement path="${plugins.dir}/org.eclipse.core.runtime_3.2.0.v20060603.jar" />
                       <pathelement path="${plugins.dir}/org.eclipse.osgi_3.2.2.R32x_v20070118.jar" />
                       <pathelement path="${plugins.dir}/org.eclipse.equinox.common_3.2.0.v20060603.jar" />
                       <pathelement path="${plugins.dir}/org.eclipse.core.jobs_3.2.0.v20060603.jar" />
                       <pathelement path="${plugins.dir}/org.eclipse.equinox.registry_3.2.1.R32x_v20060814.jar"/>
                       <pathelement path="${plugins.dir}/org.eclipse.equinox.preferences_3.2.1.R32x_v20060717.jar"/>
                       <pathelement path="${plugins.dir}/org.eclipse.core.contenttype_3.2.0.v20060603.jar" />
                       <pathelement path="${plugins.dir}/org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601.jar"/>
                       <pathelement path="${plugins.dir}/org.eclipse.update.configurator_3.2.2.R32x_v20070111.jar"/>
                       <pathelement path="${plugins.dir}/org.eclipse.ant.core_3.1.100.v20060531.jar" />
                       <pathelement path="${plugins.dir}/org.eclipse.core.variables_3.1.100.v20060605.jar" />
                       <pathelement path="${plugins.dir}/org.eclipse.core.expressions_3.2.2.r322_v20070109a.jar"/>
                       <pathelement path="${plugins.dir}/org.eclipse.core.filesystem_1.0.0.v20060603.jar" />
                       <pathelement path="${plugins.dir}/org.eclipse.text_3.2.0.v20060605-1400.jar" />
                       <pathelement path="${plugins.dir}/org.eclipse.core.commands_3.2.0.I20060605-1400.jar" />
                       <pathelement path="${plugins.ajde.loc}/ajde.jar" />
                       <pathelement path="${plugins.weaver.loc}/aspectjweaver.jar" />
                       <pathelement path="${plugins.aspectjrt.loc}/aspectjrt.jar" />
               </path>

               <path id="user.classpath">
                       <pathelement path="C:\downloads\Java\Libs\apache\ant\1.7\lib\ant.jar" />
                       <pathelement path="C:/Program Files/Java/jdk1.5.0_11/jre/lib/rt.jar" />
                       <pathelement path="C:/Program Files/Java/jdk1.5.0_11/jre/lib/jsse.jar" />
                       <pathelement path="C:/Program Files/Java/jdk1.5.0_11/jre/lib/jce.jar" />
                       <pathelement path="C:/Program Files/Java/jdk1.5.0_11/jre/lib/charsets.jar" />
                       <pathelement path="C:/Program Files/Java/jdk1.5.0_11/jre/lib/ext/dnsns.jar" />
                       <pathelement path="C:/Program Files/Java/jdk1.5.0_11/jre/lib/ext/jsk-policy.jar" />
                       <pathelement path="C:/Program Files/Java/jdk1.5.0_11/jre/lib/ext/localedata.jar" />
                       <pathelement path="C:/Program Files/Java/jdk1.5.0_11/jre/lib/ext/sunjce_provider.jar" />
                       <pathelement path="C:/Program Files/Java/jdk1.5.0_11/jre/lib/ext/sunpkcs11.jar" />
               </path>

               <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
                       <classpath refid="ajde.classpath" />
               </taskdef>

       </target>

       <target name="build" depends="init">
               <delete dir="/bin" />
               <mkdir dir="/bin" />

               <iajc destDir="/bin" failonerror="true" verbose="true" fork="true" maxmem="512m">
                       <forkclasspath refid="ajde.classpath" />
                       <forkclasspath refid="user.classpath" />
                       <src path="com/" />
               </iajc>
       </target>
</project>

==================
Ant Output
==================
Buildfile: C:\workspace\AsjectJ_test\build.xml
init:
build:
  [delete] Deleting directory C:\bin
   [mkdir] Created dir: C:\bin
    [iajc] ajc [-d, C:\bin, -verbose,
C:\workspace\AsjectJ_test\com\oreilly\aspectjcookbook\HelloWorld.aj,
C:\workspace\AsjectJ_test\com\oreilly\aspectjcookbook\MyClass.java]
    [iajc] forking [C:\Program Files\Java\jdk1.5.0_11\jre\bin\javaw.exe,
-Xmx512m, -classpath, C:\Program
Files\eclipse\plugins\org.eclipse.core.resources_3.2.2.R32x_v20061218.jar;C:\Program
Files\eclipse\plugins\org.eclipse.core.runtime.compatibility_3.1.100.v20060603.jar;C:\Program
Files\eclipse\plugins\org.eclipse.core.runtime_3.2.0.v20060603.jar;C:\Program
Files\eclipse\plugins\org.eclipse.osgi_3.2.2.R32x_v20070118.jar;C:\Program
Files\eclipse\plugins\org.eclipse.equinox.common_3.2.0.v20060603.jar;C:\Program
Files\eclipse\plugins\org.eclipse.core.jobs_3.2.0.v20060603.jar;C:\Program
Files\eclipse\plugins\org.eclipse.equinox.registry_3.2.1.R32x_v20060814.jar;C:\Program
Files\eclipse\plugins\org.eclipse.equinox.preferences_3.2.1.R32x_v20060717.jar;C:\Program
Files\eclipse\plugins\org.eclipse.core.contenttype_3.2.0.v20060603.jar;C:\Program
Files\eclipse\plugins\org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601.jar;C:\Program
Files\eclipse\plugins\org.eclipse.update.configurator_3.2.2.R32x_v20070111.jar;C:\Program
Files\eclipse\plugins\org.eclipse.ant.core_3.1.100.v20060531.jar;C:\Program
Files\eclipse\plugins\org.eclipse.core.variables_3.1.100.v20060605.jar;C:\Program
Files\eclipse\plugins\org.eclipse.core.expressions_3.2.2.r322_v20070109a.jar;C:\Program
Files\eclipse\plugins\org.eclipse.core.filesystem_1.0.0.v20060603.jar;C:\Program
Files\eclipse\plugins\org.eclipse.text_3.2.0.v20060605-1400.jar;C:\Program
Files\eclipse\plugins\org.eclipse.core.commands_3.2.0.I20060605-1400.jar;C:\downloads\Java\Libs\AspectJ\1.5.4\aspectjrt.jar;C:\downloads\Java\Libs\AspectJ\1.5.4\aspectjtools.jar;C:\downloads\Java\Libs\AspectJ\1.5.4\aspectjweaver.jar;C:\downloads\Java\Libs\apache\ant\1.7\lib\ant.jar;C:\Program
Files\Java\jdk1.5.0_11\jre\lib\rt.jar;C:\Program
Files\Java\jdk1.5.0_11\jre\lib\jsse.jar;C:\Program
Files\Java\jdk1.5.0_11\jre\lib\jce.jar;C:\Program
Files\Java\jdk1.5.0_11\jre\lib\charsets.jar;C:\Program
Files\Java\jdk1.5.0_11\jre\lib\ext\dnsns.jar;C:\Program
Files\Java\jdk1.5.0_11\jre\lib\ext\jsk-policy.jar;C:\Program
Files\Java\jdk1.5.0_11\jre\lib\ext\localedata.jar;C:\Program
Files\Java\jdk1.5.0_11\jre\lib\ext\sunjce_provider.jar;C:\Program
Files\Java\jdk1.5.0_11\jre\lib\ext\sunpkcs11.jar,
org.aspectj.tools.ajc.Main, -d, C:\bin, -verbose,
C:\workspace\AsjectJ_test\com\oreilly\aspectjcookbook\HelloWorld.aj,
C:\workspace\AsjectJ_test\com\oreilly\aspectjcookbook\MyClass.java]
    [iajc]
C:\workspace\AsjectJ_test\com\oreilly\aspectjcookbook\MyClass.java:9 [error]
The type List is not generic; it cannot be parameterized with arguments
<String>
    [iajc] List<String> s = new ArrayList<String>();
    [iajc] ^^
    [iajc]
C:\workspace\AsjectJ_test\com\oreilly\aspectjcookbook\MyClass.java:9 [error]
Syntax error, parameterized types are only available if source level is 5.0
    [iajc] List<String> s = new ArrayList<String>();
    [iajc] ^^^^
    [iajc]
C:\workspace\AsjectJ_test\com\oreilly\aspectjcookbook\MyClass.java:9 [error]
The type ArrayList is not generic; it cannot be parameterized with arguments
<String>
    [iajc] List<String> s = new ArrayList<String>();
    [iajc] ^^^^^^^
    [iajc]
C:\workspace\AsjectJ_test\com\oreilly\aspectjcookbook\MyClass.java:9 [error]
Syntax error, parameterized types are only available if source level is 5.0
    [iajc] List<String> s = new ArrayList<String>();
    [iajc] ^^^^
    [iajc] 4 errors

BUILD FAILED
C:\workspace\AsjectJ_test\build.xml:63: compile errors: 4

Total time: 2 seconds
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Dean Wampler, Ph.D.
dean at objectmentor.com
See also:
http://aquarium.rubyforge.org     AOP for Ruby
http://www.contract4j.org         Design by Contract for Java5




Back to the top