This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 242756

Summary: StringIndexOutOfBoundsException: String index out of range: -1
Product: java Reporter: Michel Graciano <hmichel>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: RESOLVED WONTFIX    
Severity: normal CC: gualtiero65, hmichel
Priority: P3    
Version: 8.0   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 206994
Attachments: stacktrace
stacktrace
stacktrace

Description Michel Graciano 2014-03-10 19:10:22 UTC
Build: NetBeans IDE Dev (Build 20140227-8aabb71e3f6d)
VM: Java HotSpot(TM) 64-Bit Server VM, 24.0-b56, Java(TM) SE Runtime Environment, 1.7.0_40-b43
OS: Linux

User Comments:
GUEST: Added the @data annotation from lombok to a class

gualtiero65: Opening a new file in the editor

hmichel: Opening a class file




Stacktrace: 
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
   at java.lang.String.substring(String.java:1904)
   at java.lang.String.subSequence(String.java:1946)
   at org.netbeans.modules.java.hints.errors.Utilities.resolveAlternativeInvocation(Utilities.java:1792)
   at org.netbeans.modules.java.hints.errors.Utilities.checkAlternativeInvocation(Utilities.java:1664)
   at org.netbeans.modules.java.hints.suggestions.TooStrongCast.checkAmbiguous(TooStrongCast.java:245)
   at org.netbeans.modules.java.hints.suggestions.TooStrongCast.broadTypeCast(TooStrongCast.java:174)
Comment 1 Michel Graciano 2014-03-10 19:10:25 UTC
Created attachment 145911 [details]
stacktrace
Comment 2 Michel Graciano 2014-03-10 19:16:07 UTC
Created attachment 145912 [details]
stacktrace

Opening a class with a bunch of lombok annotations
Comment 3 Michel Graciano 2014-03-20 16:45:29 UTC
Created attachment 146184 [details]
stacktrace

Opening a file with Lombok annotations
Comment 4 Exceptions Reporter 2014-03-20 16:45:34 UTC
This bug already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=206994
Comment 5 Svata Dedic 2014-03-21 12:46:52 UTC
Cause by Lombok; some inserted tree parts do not have positions. The code in question attempts to alter source to ensure the result will resolve correctly - I can make the issue less irritating by pretending the alternative call would be ambiguous which would suppress the hint, but at the same time may leave some situations unnoticed.

More elaborate fix (which could be done later) could involve pretty-printing part of the source tree possibly generated by Lombok and reparsing it back.

Leaving open, exception should be avoided by jet-main#b8199830f4b9
Comment 6 Quality Engineering 2014-04-05 03:29:09 UTC
Integrated into 'main-silver', will be available in build *201404050001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/b8199830f4b9
User: Svata Dedic <sdedic@netbeans.org>
Log: #242756: ignore synthesized trees
Comment 7 Martin Balin 2016-07-07 07:17:50 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss