Hi, I tried to create a TypeReference, using
recoder.kit.TypeKit.createTypeReference, related to this type:
LinkedHashMap<K, V>();
K and V are mapped as
recoder.service.DefaultProgramModelInfo.WrappedTypeArgument.
The qualified names of K and V are:
- net.sf.retrotranslator.transformer.ClassReplacement.<numeric id="">.K
- net.sf.retrotranslator.transformer.ClassReplacement.<numeric id="">.V
None of them are valid java identifiers so when I tried to create a type
reference I received the following exception:
java.lang.IllegalArgumentException: 29292008 is not a valid Java identifier
at recoder.java.Identifier.<init>(Identifier.java:62)
at recoder.java.JavaProgramFactory.createIdentifier(JavaProgramFactory.java:1218)
at recoder.kit.MiscKit.createUncollatedReferenceQualifier(MiscKit.java:71)
at recoder.kit.TypeKit.createTypeReference(TypeKit.java:123)
at recoder.kit.TypeKit.createTypeReference(TypeKit.java:98)
at recoder.kit.TypeKit.makeTypeArgRef(TypeKit.java:133)
at recoder.kit.TypeKit.createTypeReference(TypeKit.java:166)
at recoder.kit.TypeKit.createTypeReference(TypeKit.java:202)
I patched this bug creating another constructor of Identifier which takes two
arguments:
public Identifier(UncollatedReferenceQualifier ref, String text)
This constructor doesn't check if text is a valid java identifier.
I saw a problem such like this when I tried to create type reference of an
anonymous class. I solved that problem creating a type reference of the super
class of the anonymous class.
I'd like to know if there are other solutions related to these problems.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, first about anonymous classes: It's not possible to create type
references to them. Creating references to the super class instead seems like
a good idea. I don't see a problem with that.
About the problem you describe above: Can you provide a minimal example
(including your source code that makes use of Recoder)?
Regards,
Tobias
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
thank you for your reply :-) We are analyzing the code of RECODER (including
retrotranslator) in order to test our tool. The class where the exceptions
above arose is: net.sf.retrotranslator.transformer.ClassReplacement at line
120.
I've just discovered that it was my fault. In the source code I try to make a
type reference using the type of the parameter given by the method signature
of the "synchronizedMap" method (which is java.util.Map<null, null="">) instead
of the type of the expression (new LinkedHashMap<K,V>()) which is correctly
java.util.LinkedHashMap<K,V>. Using the last type the method
TypeKit.createTypeReference(...) works properly.
Thanks a lot.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I tried to create a TypeReference, using
recoder.kit.TypeKit.createTypeReference, related to this type:
K and V are mapped as
recoder.service.DefaultProgramModelInfo.WrappedTypeArgument.
The qualified names of K and V are:
- net.sf.retrotranslator.transformer.ClassReplacement.<numeric id="">.K
- net.sf.retrotranslator.transformer.ClassReplacement.<numeric id="">.V
None of them are valid java identifiers so when I tried to create a type
reference I received the following exception:
I patched this bug creating another constructor of Identifier which takes two
arguments:
This constructor doesn't check if text is a valid java identifier.
I saw a problem such like this when I tried to create type reference of an
anonymous class. I solved that problem creating a type reference of the super
class of the anonymous class.
I'd like to know if there are other solutions related to these problems.
Hej,
Well, first about anonymous classes: It's not possible to create type
references to them. Creating references to the super class instead seems like
a good idea. I don't see a problem with that.
About the problem you describe above: Can you provide a minimal example
(including your source code that makes use of Recoder)?
Regards,
Tobias
Hi,
thank you for your reply :-) We are analyzing the code of RECODER (including
retrotranslator) in order to test our tool. The class where the exceptions
above arose is: net.sf.retrotranslator.transformer.ClassReplacement at line
120.
I've just discovered that it was my fault. In the source code I try to make a
type reference using the type of the parameter given by the method signature
of the "synchronizedMap" method (which is java.util.Map<null, null="">) instead
of the type of the expression (new LinkedHashMap<K,V>()) which is correctly
java.util.LinkedHashMap<K,V>. Using the last type the method
TypeKit.createTypeReference(...) works properly.
Thanks a lot.