RFR 8054213: Class name repeated in output of Type.toString()
Svetlana Nikandrova
svetlana.nikandrova at oracle.com
Thu Jun 30 16:44:58 UTC 2016
Hello Joe,
thank you for your advice! GenericStringTest looks really good with
annotations. I refactored my test, please see updated webrev:
http://cr.openjdk.java.net/~snikandrova/8054213/webrev.01/
<http://cr.openjdk.java.net/%7Esnikandrova/8054213/webrev.01/>
As for "." vs "$" let me provide an example:
E.g. we have class
public classTest {
publicNested1<Test>.Nested2<Test> foo()
{
return null;
}
public classNested1<T>
{
public classNested2<T>{}
}
}
The output of the
System.out.println(Test.class.getMethod("foo",null).getReturnType());
Output:
class Test$Nested1$Nested2 (nested classes divided by "$")
while
System.out.println(Test.class.getMethod("foo",null).getGenericReturnType());
Output:
Test$Nested1<Test>.Nested2<Test>(nested classes divided by "." if enclosed by parametrized type and "$" in other cases).
I think it's a little bit strange to have different separators for inner
classes depended on is it nested by parametrized or raw type.
Thank you,
Svetlana
On 28.06.2016 22:02, joe darcy wrote:
> Hello Svetlana,
>
> I'm not convinced '$' should be replaced with '.' in this context as
> '.' is what the separator used in source code.
>
> In any case, the test should be restructured. I recommend declaring an
> annotation type to hold the expected to string output. You can them
> loop over the methods from the class object and for the methods with
> the annotation verifying the toString output is as expected. For a
> guide see
>
> test/java/lang/reflect/Constructor/GenericStringTest.java
>
> Thanks,
>
> -Joe
>
>
> On 6/28/2016 11:25 AM, Svetlana Nikandrova wrote:
>> May be someone can find a minute?
>>
>> On 27.06.2016 21:25, Svetlana Nikandrova wrote:
>>> Kindly reminder
>>>
>>> On 24.06.2016 14:58, Svetlana Nikandrova wrote:
>>>> Hello,
>>>>
>>>> let me try again with updated version of webrev:
>>>> Webrev:
>>>> http://cr.openjdk.java.net/~snikandrova/8054213/webrev.01/
>>>> <http://cr.openjdk.java.net/%7Esnikandrova/8054213/webrev.01/>
>>>> Issue:
>>>> https://bugs.openjdk.java.net/browse/JDK-8054213
>>>>
>>>> Many thanks goes to Sergey Ustimenko for his valuable advises. I
>>>> believe fix looks nicer now.
>>>> JPRT tested.
>>>>
>>>> Thank you,
>>>> Svetlana
>>>>
>>>> On 17.06.2016 21:45, Svetlana Nikandrova wrote:
>>>>> Hello,
>>>>>
>>>>> could you please review this fix for toString() method of
>>>>> ParameterizedTypeImpl.
>>>>> The problem is that when we obtain simple name of nested type
>>>>> shared prefix is only removed for ParameterizedType owner. We need
>>>>> to remove it for other cases too.
>>>>>
>>>>> Please note that I also changed delimiter between outer and inner
>>>>> class from "." to "$". I believe as "$" is usually used to
>>>>> separate nested class name "." looks inconsistent and confusing.
>>>>> Let me know if you have any objections.
>>>>>
>>>>> Webrev:
>>>>> http://cr.openjdk.java.net/~msolovie/8054213/webrev.00/
>>>>> <http://cr.openjdk.java.net/%7Emsolovie/8054213/webrev.00/>
>>>>> Issue:
>>>>> https://bugs.openjdk.java.net/browse/JDK-8054213
>>>>>
>>>>> Thank you,
>>>>> Svetlana
>>>>
>>>
>>
>
More information about the core-libs-dev
mailing list