-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Parse error with xdoclet and JDK 1.5 generics?
PostPosted: Fri Jul 30, 2004 7:21 pm 
Newbie

Joined: Fri Jul 30, 2004 7:07 pm
Posts: 12
Generating hibernate mapping files fails if the source file contains generics (ala JDK 1.5.Tiger)

[hibernatedoclet] Error parsing File Account.java:Encountered "<" at line 73, column 16.
[hibernatedoclet] Was expecting one of:
[hibernatedoclet] <IDENTIFIER> ...
[hibernatedoclet] "[" ...
[hibernatedoclet] "." ...
[hibernatedoclet] "(" ...
[hibernatedoclet]

The offending line is the location of a generic collection:

private Set<Permission> permissions;

Note that at this point in the class file, there have been no xdoclet annotations (they start lower down in the file).

This may not be hibernate specifc?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 31, 2004 1:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Direct this one to the XDoclet crew. Interesting headsup though.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 31, 2004 9:00 pm 
Newbie

Joined: Fri Jul 30, 2004 7:07 pm
Posts: 12
I was unclear the full intent of your comment.

1) Are you saying I need to send a message to some other party?

2) Is the problem with XDoclet in general or the hibernate module for xdoclet?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 01, 2004 8:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
It appears that the XDoclet parser doesn't like the generics syntax (which is not a surprise really). So its an XDoclet core issue.


Top
 Profile  
 
 Post subject: bad news for all xdoclet users
PostPosted: Mon Sep 27, 2004 7:39 am 
Beginner
Beginner

Joined: Wed Mar 10, 2004 9:51 am
Posts: 42
Location: France
I've been communicating with the xdoclet guys and they expect to
have support for java 1.5 sometime arround january.

as per bug ....

http://opensource.atlassian.com/project ... wse/XJD-41

I want to move my code to java 1.5/hibernate 3 as well ....

Perhaps everyone affected should vote for this bug.

--b

_________________
Pesimist: The glass is half empty
Optimist: The glass is half full
Engineer:The glass should be half that size


Top
 Profile  
 
 Post subject: Workround to work with xdoclet & generics
PostPosted: Sun Oct 03, 2004 9:08 am 
Beginner
Beginner

Joined: Sun Aug 29, 2004 7:21 pm
Posts: 26
For the one impatients of using jdk5 like me, here is a workaround I use to be able to get generics, and still have xdoclet running :

I add a small ant task that parse all my sources with a regex, removing all the generics, and all the declaration of the foreach loops.

The resulting code isn't functional, but it's good enough to run xdoclet on it.

Note, the regex works fine for me, but it might need to be improved for more complex cases.
Right now, the most complex handled case is simething like :
Code:
<String,byte[]>


So, here is the ant task :

Code:
<target name="remove-generics" depends="init">
   <!-- Since XDoclet isn't already able to parse java 1.5 source code,
      we remove all references to generics and for each loops. -->
   <property name="generics.match.pattern" value="&lt;[\w\[\]]+(&lt;\w+&gt;)?,?[\w\[\]]*(&lt;\w+&gt;)?&gt;|(for\s?\(.+:.+\))"/>
   <echo message="Pattern used to remove generics : ${generics.match.pattern}"/>
   <copy toDir="${build.generate.dir}/java" overwrite="true">
      <fileset dir="${src.main.dir}">
         <include name="**/*.java"/>
      </fileset>
   </copy>
   <replaceregexp byline="true" flags="g">
      <fileset dir="${build.generate.dir}/java">
         <include name="**/*.java"/>
      </fileset>
      <regexp pattern="${generics.match.pattern}"/>
      <substitution expression=""/>
   </replaceregexp>
</target>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.