[hg] main-silver: #224764 - ArrayIndexOutOfBoundsException: -536...

  • From: Miloslav Metelka < >
  • To: ,
  • Subject: [hg] main-silver: #224764 - ArrayIndexOutOfBoundsException: -536...
  • Date: Mon, 04 Feb 2013 13:37:24 -0800

changeset ce36d904b8a7 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/ce36d904b8a7
description:
        #224764 - ArrayIndexOutOfBoundsException: -536869843 - added 
assertions with highlights view factory and view builder dump.

diffstat:

 editor.lib2/src/org/netbeans/modules/editor/lib2/view/EditorViewFactory.java 
    |  10 ++++++-
 
editor.lib2/src/org/netbeans/modules/editor/lib2/view/HighlightsViewFactory.java
 |  12 +++------
 editor.lib2/src/org/netbeans/modules/editor/lib2/view/ViewBuilder.java       
    |  10 ++-----
 3 files changed, 15 insertions(+), 17 deletions(-)

diffs (107 lines):

diff --git 
a/editor.lib2/src/org/netbeans/modules/editor/lib2/view/EditorViewFactory.java
 
b/editor.lib2/src/org/netbeans/modules/editor/lib2/view/EditorViewFactory.java
--- 
a/editor.lib2/src/org/netbeans/modules/editor/lib2/view/EditorViewFactory.java
+++ 
b/editor.lib2/src/org/netbeans/modules/editor/lib2/view/EditorViewFactory.java
@@ -295,6 +295,12 @@
         this.viewBuilder = viewBuilder;
     }
 
+    @Override
+    public String toString() {
+        ViewBuilder vb = viewBuilder;
+        return "viewBuilder:\n" + vb; // NOI18N
+    }
+
     /**
      * Change that occurred in a view factory either due to insert/remove in 
a document
      * or due to some other cause.
@@ -302,9 +308,9 @@
      */
     public static final class Change {
 
-        private int startOffset;
+        private final int startOffset;
 
-        private int endOffset;
+        private final int endOffset;
 
         Change(int startOffset, int endOffset) {
             this.startOffset = startOffset;
diff --git 
a/editor.lib2/src/org/netbeans/modules/editor/lib2/view/HighlightsViewFactory.java
 
b/editor.lib2/src/org/netbeans/modules/editor/lib2/view/HighlightsViewFactory.java
--- 
a/editor.lib2/src/org/netbeans/modules/editor/lib2/view/HighlightsViewFactory.java
+++ 
b/editor.lib2/src/org/netbeans/modules/editor/lib2/view/HighlightsViewFactory.java
@@ -213,7 +213,9 @@
     @Override
     public EditorView createView(int startOffset, int limitOffset, boolean 
forcedLimit,
     EditorView origView, int nextOrigViewOffset) {
-        assert (startOffset < limitOffset) : "startOffset=" + startOffset + 
" >= limitOffset=" + limitOffset; // NOI18N
+        assert (startOffset >= 0) : "Invalid startOffset=" + startOffset + " 
< 0\nHVF: " + this; // NOI18N
+        assert (startOffset < limitOffset) : "startOffset=" + startOffset + 
// NOI18N
+                " >= limitOffset=" + limitOffset + "\nHVF: " + this; // 
NOI18N
         // Possibly update lineEndOffset since updateHighlight() will read 
till it
         updateLineEndOffset(startOffset);
         HighlightsList hList = highlightsReader.highlightsList();
@@ -410,19 +412,13 @@
 
     @Override
     public String toString() {
-        return toString(Integer.MIN_VALUE);
-    }
-    
-    public String toString(int offset) {
         StringBuilder sb = new StringBuilder(100);
-        if (offset != Integer.MIN_VALUE) {
-            sb.append("offset=").append(offset).append(", "); // NOI18N
-        }
         sb.append("lineIndex=").append(lineIndex). // NOI18N
                 append(", lineEndOffset=").append(lineEndOffset). // NOI18N
                 append(", charType=").append(charType). // NOI18N
                 append(", nextTabOrRTLOffset=").append(nextTabOrRTLOffset). 
// NOI18N
                 append(", nextCharType=").append(nextCharType); // NOI18N
+        sb.append(", ").append(super.toString());
         return sb.toString();
     }
 
diff --git 
a/editor.lib2/src/org/netbeans/modules/editor/lib2/view/ViewBuilder.java 
b/editor.lib2/src/org/netbeans/modules/editor/lib2/view/ViewBuilder.java
--- a/editor.lib2/src/org/netbeans/modules/editor/lib2/view/ViewBuilder.java
+++ b/editor.lib2/src/org/netbeans/modules/editor/lib2/view/ViewBuilder.java
@@ -816,7 +816,6 @@
                 // Only the bottommost highlights-view-factory should always 
respect the the limitOffset.
                 EditorView createdView = null;
                 int createdViewEndOffset;
-                boolean creationFailed = false;
                 if (createLocalViews) { // Regular views creation
                     // Prepare original view if possible
                     EditorView origView; // null means no view to reuse
@@ -893,7 +892,6 @@
                     
                     createdView = state.factory.createView(creationOffset, 
limitOffset, forcedLimit, origView, nextOrigViewOffset);
                     if (createdView == null) { // Creation refused
-                        creationFailed = true;
                         createdViewEndOffset = -1; // Ignored; will not 
reach updateLine()
                     } else {
                         int viewLength = createdView.getLength();
@@ -902,13 +900,11 @@
                     }
 
                 } else { // Do not create local views
+                    // createdViewEndOffset may be -1 to signal that factory 
does not want to create view here.
                     createdViewEndOffset = 
state.factory.viewEndOffset(creationOffset, limitOffset, forcedLimit);
-                    if (createdViewEndOffset == -1) { // Refused => Use a 
next factory
-                        creationFailed = true;
-                    }
                 }
 
-                if (creationFailed) {
+                if (createdViewEndOffset == -1) { // View creation refused 
by this factory
                     // Rescan the factory at next offset since it may 
request another view creation
                     // within the area which may lower limitOffset
                     state.updateNextViewStartOffset(creationOffset + 1);
@@ -916,7 +912,7 @@
                         forcedLimit = true;
                         limitOffset = state.nextViewStartOffset;
                     }
-                    continue;
+                    continue; // Continue with next factory to possibly 
create a view
                 }
 
                 updateLine(createdViewEndOffset);

[hg] main-silver: #224764 - ArrayIndexOutOfBoundsException: -536...

Miloslav Metelka 02/04/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close