[9] RFR(S): 8148752: Compiled StringBuilder code throws StringIndexOutOfBoundsException

Tobias Hartmann tobias.hartmann at oracle.com
Tue Feb 9 14:18:48 UTC 2016

Roland, Aleksey, Vladimir, thanks for the reviews!

Here is the regression test:

It fails because Object o is casted to String:

Exception in thread "main" java.lang.RuntimeException: Test failed
	at LongReferenceCastingTest.main(LongReferenceCastingTest.java:68)
Caused by: java.lang.NullPointerException
	at java.lang.StringLatin1.equals(StringLatin1.java:92)
	at java.lang.String.equals(String.java:1002)
	at LongReferenceCastingTest.main(LongReferenceCastingTest.java:63)


On 09.02.2016 13:56, Vladimir Ivanov wrote:
> Looks good.
> If possible, please, provide a test case.
> Best regards,
> Vladimir Ivanov
> PS: the bug is there from day #0. I am surprised it hasn't been discovered for so long...
> On 2/9/16 3:01 PM, Tobias Hartmann wrote:
>> Hi,
>> please review the following patch.
>> https://bugs.openjdk.java.net/browse/JDK-8148752
>> http://cr.openjdk.java.net/~thartmann/8148752/webrev.00/
>> GraphBuilder::try_method_handle_inline() handles long and double arguments incorrectly when casting them to their actual type. Long/double arguments occupy two slots (see Parse::do_get_xxx() -> push_pair()). Currently, these two slots are treated as two individual arguments, causing incorrect casting of arguments.
>> In this case, an Object argument is casted to String and therefore being used as a String (although it's actually of type 'ResolvedJavaMethod'). We later fail by throwing exceptions in compiled code. For a detailed evaluation see my comments in the bug [1].
>> We should handle this like C1 does in GraphBuilder::try_method_handle_inline().
>> Thanks,
>> Tobias
>> [1] https://bugs.openjdk.java.net/browse/JDK-8148752?focusedCommentId=13896557&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13896557

More information about the hotspot-compiler-dev mailing list