You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Frederic Ahring <FA...@de.ibm.com> on 2005/07/27 19:05:34 UTC

Source Reflection: JavaQNameImpl.getInstance(String, true) in JavaSource.newJavaField

Hi, it's me again :)

I noticed that when parsing a class with fields these fields are stored as 
JavaQNames, but the Classname e.g. "java.lang.String" is not split into 
package (java.lang) and class (String), but kept as a whole as classname. 
This behavior can be changed when using 
JavaQNameImpl.getInstance(classname) with the form 
JavaQNameImpl.getInstance(classname, true).

I checked JavaSource.newJavaField and found it in three places. Below is a 
diff.

I don't know if this will break anything, I assume it will not and it was 
merely forgotten. Please correct me if I'm wrong and it was intentionally 
done.

Jochen: this fixes the problem for me. It still is not a complete parser 
and still doesn't add the current package if no package is given. And it 
was not JavaParser.getQName(String) - there the true-parameter is used.


--- JavaSource_old.java 2005-07-27 18:28:45.000000000 +0200
+++ JavaSource.java     2005-07-27 18:33:51.000000000 +0200
@@ -1164,14 +1164,14 @@
      * protection.
      */
     public JavaField newJavaField(String pName, String pType, Protection 
pProtection) {
-       return newJavaField(pName, JavaQNameImpl.getInstance(pType), 
pProtection);
+       return newJavaField(pName, JavaQNameImpl.getInstance(pType, true), 
pProtection);
     }
 
     /** Creates a new JavaField with the given name, type and
      * protection.
      */
     public JavaField newJavaField(String pName, String pType, String 
pProtection) {
-       return newJavaField(pName, JavaQNameImpl.getInstance(pType),
+       return newJavaField(pName, JavaQNameImpl.getInstance(pType, true),
                        Protection.valueOf(pProtection));
     }
 
@@ -1179,7 +1179,7 @@
      * default protection.
      */
     public JavaField newJavaField(String pName, String pType) {
-       return newJavaField(pName, JavaQNameImpl.getInstance(pType), 
(Protection) null);
+       return newJavaField(pName, JavaQNameImpl.getInstance(pType, true), 
(Protection) null);
     }
 
     /** Creates a new JavaField with the given name, type and


:Frederic:

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: Source Reflection: JavaQNameImpl.getInstance(String, true) in JavaSource.newJavaField

Posted by Jochen Wiedmann <jo...@gmail.com>.
Frederic Ahring wrote:

> Do I understand you right that this patch is for 0.5 and you ask me if it 
> patches correctly a 0.4, too? Well, I can't say, I don't have 'patch' 
> laying around here (and would manually implement the changes).

No, it's definitely *not* applicable to 0.4. I suggest that you try to 
apply it to

   http://www.apache.de/dist/ws/jaxme/source/ws-jaxme-0.5beta-src.tar.gz


> Actually I didn't apply the patch but changed getInstance and then fixed 
> all now broken calls. I assume this to be what you've done, but haven't 
> checked if the patches would be equal.

Sounds so. :-)


> It seems to work.
> 
> Actually it seems to be much slower now, but this could have other reasons 
> as well.

I have no explanation for that, assuming that we did indeed do the same 
thing. Anyways, I'll apply the patch tonight.


Jochen

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: Source Reflection: JavaQNameImpl.getInstance(String, true) in JavaSource.newJavaField

Posted by Frederic Ahring <FA...@de.ibm.com>.
Hi, Jochen...

> > I checked JavaSource.newJavaField and found it in three places. Below 
is a 
> > diff.
> It seems, you are using the 0.4 branch. 
Actually I don't know :)
I think I downloaded the source archive from one of the mirrors ("The 
preferred way to obtain JaxMe distributions"), so I don't have current CVS 
versions. I know it would be better setting up CVS when I'm actually 
giving out patches, but then again I thought your framework was so perfect 
there would be no need :)

> Applies you find a suggested patch for the HEAD (aka 0.5) branch. 
Do I understand you right that this patch is for 0.5 and you ask me if it 
patches correctly a 0.4, too? Well, I can't say, I don't have 'patch' 
laying around here (and would manually implement the changes).

Or was the question if this patch showes the correct behavior? I assume so 
- as far as I see it you just set the default value of assumePackage from 
false to true and eliminating the choice alltogether. I thought about 
this, too, but didn't know if there was a reason behind it being possible 
to explicitely set to false. I think this way is better.

> (It simply eliminates getInstance(String).)
AND sets assumePackage to true :)



> --- ant/docs.xml   14 Jul 2005 20:27:37 -0000   1.5
> -    <target name="javadoc" depends="all"
> +    <target name="javadoc" depends="PM.all"
don't know what this does, won't touch

Actually I didn't apply the patch but changed getInstance and then fixed 
all now broken calls. I assume this to be what you've done, but haven't 
checked if the patches would be equal.

It seems to work.

Actually it seems to be much slower now, but this could have other reasons 
as well.

:Frederic:

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: Source Reflection: JavaQNameImpl.getInstance(String, true) in JavaSource.newJavaField

Posted by Jochen Wiedmann <jo...@gmail.com>.
Frederic Ahring wrote:

> I checked JavaSource.newJavaField and found it in three places. Below is a 
> diff.

It seems, you are using the 0.4 branch. Applies you find a suggested 
patch for the HEAD (aka 0.5) branch. (Note, that 0.5 beta is already out
and 0.5final will most likely be published in two weeks.) Does that work
as well? (It simply eliminates getInstance(String).)

Jochen