[hg] main-silver: #237479 - java.lang.IndexOutOfBoundsException:...

  • From: Miloslav Metelka < >
  • To:
  • Subject: [hg] main-silver: #237479 - java.lang.IndexOutOfBoundsException:...
  • Date: Tue, 12 Nov 2013 21:57:03 +0000

changeset 1d1a0b5dc515 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/1d1a0b5dc515
description:
        #237479 - java.lang.IndexOutOfBoundsException: start=-1073737142 < 0 
in DefaultToken.text().

diffstat:

 lexer/src/org/netbeans/lib/lexer/BatchTokenList.java              |   5 +++
 lexer/src/org/netbeans/lib/lexer/EmbeddedTokenList.java           |   4 +--
 lexer/src/org/netbeans/lib/lexer/EmbeddingOperation.java          |   7 ++--
 lexer/src/org/netbeans/lib/lexer/JoinTokenList.java               |   8 ++---
 lexer/src/org/netbeans/lib/lexer/LexerUtilsConstants.java         |   8 +++++
 lexer/src/org/netbeans/lib/lexer/SubSequenceTokenList.java        |   5 +++
 lexer/src/org/netbeans/lib/lexer/TokenList.java                   |   9 
++++++
 lexer/src/org/netbeans/lib/lexer/inc/DocumentInput.java           |  12 
+++-----
 lexer/src/org/netbeans/lib/lexer/inc/FilterSnapshotTokenList.java |   5 +++
 lexer/src/org/netbeans/lib/lexer/inc/IncTokenList.java            |  14 
++++++++++
 lexer/src/org/netbeans/lib/lexer/inc/RemovedTokenList.java        |   5 +++
 lexer/src/org/netbeans/lib/lexer/inc/SnapshotTokenList.java       |   5 +++
 lexer/src/org/netbeans/lib/lexer/inc/TokenHierarchyUpdate.java    |   3 +-
 lexer/src/org/netbeans/lib/lexer/inc/TokenListListUpdate.java     |   4 +-
 lexer/src/org/netbeans/lib/lexer/inc/TokenListUpdater.java        |   2 +-
 lexer/src/org/netbeans/lib/lexer/token/AbstractToken.java         |   5 ++-
 lexer/src/org/netbeans/lib/lexer/token/TextToken.java             |   1 +
 17 files changed, 79 insertions(+), 23 deletions(-)

diffs (325 lines):

diff --git a/lexer/src/org/netbeans/lib/lexer/BatchTokenList.java 
b/lexer/src/org/netbeans/lib/lexer/BatchTokenList.java
--- a/lexer/src/org/netbeans/lib/lexer/BatchTokenList.java
+++ b/lexer/src/org/netbeans/lib/lexer/BatchTokenList.java
@@ -269,6 +269,11 @@
     }
 
     @Override
+    public StringBuilder dumpInfo(StringBuilder sb) {
+        return sb;
+    }
+
+    @Override
     public String dumpInfoType() {
         return "BTL";
     }
diff --git a/lexer/src/org/netbeans/lib/lexer/EmbeddedTokenList.java 
b/lexer/src/org/netbeans/lib/lexer/EmbeddedTokenList.java
--- a/lexer/src/org/netbeans/lib/lexer/EmbeddedTokenList.java
+++ b/lexer/src/org/netbeans/lib/lexer/EmbeddedTokenList.java
@@ -636,10 +636,8 @@
         
     }
 
+    @Override
     public StringBuilder dumpInfo(StringBuilder sb) {
-        if (sb == null) {
-            sb = new StringBuilder(50);
-        }
         if (isRemoved()) {
             sb.append("REMOVED-");
         }
diff --git a/lexer/src/org/netbeans/lib/lexer/EmbeddingOperation.java 
b/lexer/src/org/netbeans/lib/lexer/EmbeddingOperation.java
--- a/lexer/src/org/netbeans/lib/lexer/EmbeddingOperation.java
+++ b/lexer/src/org/netbeans/lib/lexer/EmbeddingOperation.java
@@ -187,8 +187,9 @@
                 sb.append(" ROOT-"); // NOI18N
                 LexerUtilsConstants.appendIdentityHashCode(sb, 
rootTokenList);
                 sb.append(" for ").append(embeddedLanguagePath.mimePath()). 
// NOI18N
-                        append(", ").append(embedding).append(": "). // 
NOI18N
-                        append(existingEtl.dumpInfo(null)).append(", 
initTokensInNew="). // NOI18N
+                        append(", ").append(embedding).append(": "); // 
NOI18N
+                existingEtl.dumpInfo(sb);
+                sb.append(", initTokensInNew="). // NOI18N
                         append(initTokensInNew).append('\n');
                 LOG.fine(sb.toString());
                 if (LOG.isLoggable(Level.FINER)) { // Include stack trace of 
the creation
@@ -323,7 +324,7 @@
         }
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("@@@@@@@@@@ EXPLICIT-EMBEDDING-CREATED for " + 
embeddedLanguagePath.mimePath()
-                    + ", " + embedding + ": " + etl.dumpInfo(null) + '\n');
+                    + ", " + embedding + ": " + etl.dumpInfo(new 
StringBuilder(256)) + '\n');
             if (LOG.isLoggable(Level.FINER)) { // Include stack trace of the 
creation
                 LOG.log(Level.INFO, "Explicit embedding created by:", new 
Exception());
             }
diff --git a/lexer/src/org/netbeans/lib/lexer/JoinTokenList.java 
b/lexer/src/org/netbeans/lib/lexer/JoinTokenList.java
--- a/lexer/src/org/netbeans/lib/lexer/JoinTokenList.java
+++ b/lexer/src/org/netbeans/lib/lexer/JoinTokenList.java
@@ -763,7 +763,7 @@
 //                );
         }
         assert (tokenList.joinInfo() == null) : "Non-null joinInfo in 
tokenList " +
-                tokenList.dumpInfo(null) + "\n" + tokenListList;
+                tokenList.dumpInfo(new StringBuilder(256)) + "\n" + 
tokenListList;
         tokenList.setJoinInfo(new EmbeddedJoinInfo<T>(this, joinTokenCount, 
tokenListIndex));
         return tokenList;
     }
@@ -897,10 +897,8 @@
         return null;
     }
 
+    @Override
     public StringBuilder dumpInfo(StringBuilder sb) {
-        if (sb == null) {
-            sb = new StringBuilder(256);
-        }
         sb.append("joinTokenCount=").append(joinTokenCount).
                 append(", 
activeTokenListIndex=").append(activeTokenListIndex).
                 append(", JI<").append(activeStartJoinIndex).append(",").
@@ -926,7 +924,7 @@
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder(512);
-        sb = dumpInfo(sb);
+        dumpInfo(sb);
         return LexerUtilsConstants.appendTokenList(sb, this).toString();
     }
 
diff --git a/lexer/src/org/netbeans/lib/lexer/LexerUtilsConstants.java 
b/lexer/src/org/netbeans/lib/lexer/LexerUtilsConstants.java
--- a/lexer/src/org/netbeans/lib/lexer/LexerUtilsConstants.java
+++ b/lexer/src/org/netbeans/lib/lexer/LexerUtilsConstants.java
@@ -51,6 +51,7 @@
 import org.netbeans.api.lexer.TokenHierarchy;
 import org.netbeans.api.lexer.TokenId;
 import org.netbeans.lib.editor.util.ArrayUtilities;
+import org.netbeans.lib.lexer.inc.IncTokenList;
 import org.netbeans.lib.lexer.inc.MutableTokenList;
 import org.netbeans.lib.lexer.inc.SnapshotTokenList;
 import org.netbeans.lib.lexer.inc.TokenHierarchyEventInfo;
@@ -452,6 +453,13 @@
         if (tokenList instanceof EmbeddedTokenList) {
             ((EmbeddedTokenList<?,?>)tokenList).updateModCount();
         }
+        if (tokenList instanceof IncTokenList) {
+            String error = ((IncTokenList<?>)tokenList).checkConsistency();
+            if (error != null) {
+                return error;
+            }
+        }
+        
         int startOffset = tokenList.startOffset();
         int lastOffset = startOffset;
         for (int i = 0; i < tokenCountCurrent; i++) {
diff --git a/lexer/src/org/netbeans/lib/lexer/SubSequenceTokenList.java 
b/lexer/src/org/netbeans/lib/lexer/SubSequenceTokenList.java
--- a/lexer/src/org/netbeans/lib/lexer/SubSequenceTokenList.java
+++ b/lexer/src/org/netbeans/lib/lexer/SubSequenceTokenList.java
@@ -271,6 +271,11 @@
     }
 
     @Override
+    public StringBuilder dumpInfo(StringBuilder sb) {
+        return sb;
+    }
+
+    @Override
     public String dumpInfoType() {
         return "SubSeqTL";
     }
diff --git a/lexer/src/org/netbeans/lib/lexer/TokenList.java 
b/lexer/src/org/netbeans/lib/lexer/TokenList.java
--- a/lexer/src/org/netbeans/lib/lexer/TokenList.java
+++ b/lexer/src/org/netbeans/lib/lexer/TokenList.java
@@ -323,6 +323,15 @@
     boolean isRemoved();
 
     /**
+     * Dump extra information (not token infos)
+     * about this token list to the given string builder.
+     *
+     * @param sb non-null string builder.
+     * @return sb passed as an argument.
+     */
+    StringBuilder dumpInfo(StringBuilder sb);
+
+    /**
      * Type of this token list for dump info purpose.
      *
      * @return textual token list type.
diff --git a/lexer/src/org/netbeans/lib/lexer/inc/DocumentInput.java 
b/lexer/src/org/netbeans/lib/lexer/inc/DocumentInput.java
--- a/lexer/src/org/netbeans/lib/lexer/inc/DocumentInput.java
+++ b/lexer/src/org/netbeans/lib/lexer/inc/DocumentInput.java
@@ -44,7 +44,6 @@
 
 package org.netbeans.lib.lexer.inc;
 
-import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
@@ -54,7 +53,6 @@
 import org.netbeans.lib.editor.util.swing.DocumentListenerPriority;
 import org.netbeans.lib.editor.util.swing.DocumentUtilities;
 import org.netbeans.lib.lexer.LanguageManager;
-import org.netbeans.lib.lexer.LexerApiPackageAccessor;
 import org.netbeans.spi.lexer.*;
 
 /**
@@ -150,12 +148,12 @@
 
     private void textModified(int offset, int length, CharSequence 
removedText,
     int insertedLength) {
-        try {
+//        try {
             tokenHierarchyControl().textModified(offset, length, 
removedText, insertedLength);
-        } catch (RuntimeException e) {
-            // Log the exception and attempt to recover by recreating the 
token hierarchy
-            
LexerApiPackageAccessor.get().tokenHierarchyOperation(tokenHierarchyControl().tokenHierarchy()).recreateAfterError(e);
-        }
+//        } catch (RuntimeException e) {
+//            // Log the exception and attempt to recover by recreating the 
token hierarchy
+//            
LexerApiPackageAccessor.get().tokenHierarchyOperation(tokenHierarchyControl().tokenHierarchy()).recreateAfterError(e);
+//        }
     }
 
 }
diff --git 
a/lexer/src/org/netbeans/lib/lexer/inc/FilterSnapshotTokenList.java 
b/lexer/src/org/netbeans/lib/lexer/inc/FilterSnapshotTokenList.java
--- a/lexer/src/org/netbeans/lib/lexer/inc/FilterSnapshotTokenList.java
+++ b/lexer/src/org/netbeans/lib/lexer/inc/FilterSnapshotTokenList.java
@@ -214,6 +214,11 @@
     }
 
     @Override
+    public StringBuilder dumpInfo(StringBuilder sb) {
+        return sb;
+    }
+
+    @Override
     public String dumpInfoType() {
         return "FilterSnapshotTL";
     }
diff --git a/lexer/src/org/netbeans/lib/lexer/inc/IncTokenList.java 
b/lexer/src/org/netbeans/lib/lexer/inc/IncTokenList.java
--- a/lexer/src/org/netbeans/lib/lexer/inc/IncTokenList.java
+++ b/lexer/src/org/netbeans/lib/lexer/inc/IncTokenList.java
@@ -399,6 +399,20 @@
         this.inputSourceText = text;
     }
 
+    public String checkConsistency() {
+        if (offsetGapLength() < 0) {
+            return "offsetGapLength=" + offsetGapLength() + " < 0; 
offsetGapStart=" + offsetGapStart(); // NOI18N
+        }
+        return null;
+    }
+
+    @Override
+    public StringBuilder dumpInfo(StringBuilder sb) {
+        sb.append("offGap(o=").append(offsetGapStart()). // NOI18N
+                append(",l=").append(offsetGapLength()).append(")"); // 
NOI18N
+        return sb;
+    }
+
     @Override
     public String dumpInfoType() {
         return "ITL";
diff --git a/lexer/src/org/netbeans/lib/lexer/inc/RemovedTokenList.java 
b/lexer/src/org/netbeans/lib/lexer/inc/RemovedTokenList.java
--- a/lexer/src/org/netbeans/lib/lexer/inc/RemovedTokenList.java
+++ b/lexer/src/org/netbeans/lib/lexer/inc/RemovedTokenList.java
@@ -223,6 +223,11 @@
     }
 
     @Override
+    public StringBuilder dumpInfo(StringBuilder sb) {
+        return sb;
+    }
+
+    @Override
     public String dumpInfoType() {
         return "RemovedTL";
     }
diff --git a/lexer/src/org/netbeans/lib/lexer/inc/SnapshotTokenList.java 
b/lexer/src/org/netbeans/lib/lexer/inc/SnapshotTokenList.java
--- a/lexer/src/org/netbeans/lib/lexer/inc/SnapshotTokenList.java
+++ b/lexer/src/org/netbeans/lib/lexer/inc/SnapshotTokenList.java
@@ -555,6 +555,11 @@
     }
 
     @Override
+    public StringBuilder dumpInfo(StringBuilder sb) {
+        return sb;
+    }
+
+    @Override
     public String dumpInfoType() {
         return "SnapshotTL";
     }
diff --git a/lexer/src/org/netbeans/lib/lexer/inc/TokenHierarchyUpdate.java 
b/lexer/src/org/netbeans/lib/lexer/inc/TokenHierarchyUpdate.java
--- a/lexer/src/org/netbeans/lib/lexer/inc/TokenHierarchyUpdate.java
+++ b/lexer/src/org/netbeans/lib/lexer/inc/TokenHierarchyUpdate.java
@@ -204,7 +204,8 @@
         UpdateItem<T> item = tokenListListItem(languagePath);
         if (item != null) {
             if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("THU.updateCreateOrRemoveEmbedding() add=" + add + 
": " + addedOrRemovedTokenList.dumpInfo(null));
+                LOG.fine("THU.updateCreateOrRemoveEmbedding() add=" + add + 
": " +
+                    addedOrRemovedTokenList.dumpInfo(new 
StringBuilder(256)));
             }
             if (add) {
                 
item.tokenListListUpdate.markAddedMember(addedOrRemovedTokenList);
diff --git a/lexer/src/org/netbeans/lib/lexer/inc/TokenListListUpdate.java 
b/lexer/src/org/netbeans/lib/lexer/inc/TokenListListUpdate.java
--- a/lexer/src/org/netbeans/lib/lexer/inc/TokenListListUpdate.java
+++ b/lexer/src/org/netbeans/lib/lexer/inc/TokenListListUpdate.java
@@ -162,9 +162,9 @@
                     " but real tokenListIndex is " + realIndex + // NOI18N
                     " (indexWasMinusOne=" + indexWasMinusOne + ").\n" + // 
NOI18N
                     "Wishing to remove tokenList\n" + // NOI18N
-                    ((removedTokenList != null) ? 
removedTokenList.dumpInfo(null) : "!!<NULL>!!") + // NOI18N
+                    ((removedTokenList != null) ? 
removedTokenList.dumpInfo(new StringBuilder(256)) : "!!<NULL>!!") + // NOI18N
                     "\nbut marked-for-remove tokenList is \n" + // NOI18N
-                    ((markedForRemoveTokenList != null) ? 
markedForRemoveTokenList.dumpInfo(null) : "!!<NULL>!!") + // NOI18N
+                    ((markedForRemoveTokenList != null) ? 
markedForRemoveTokenList.dumpInfo(new StringBuilder(256)) : "!!<NULL>!!") + 
// NOI18N
                     "\nfrom tokenListList\n" + tokenListList + // NOI18N
                     "\nModification description:\n" + 
eventInfo.modificationDescription(true); // NOI18N
             if (LOG.isLoggable(Level.WARNING)) {
diff --git a/lexer/src/org/netbeans/lib/lexer/inc/TokenListUpdater.java 
b/lexer/src/org/netbeans/lib/lexer/inc/TokenListUpdater.java
--- a/lexer/src/org/netbeans/lib/lexer/inc/TokenListUpdater.java
+++ b/lexer/src/org/netbeans/lib/lexer/inc/TokenListUpdater.java
@@ -623,7 +623,7 @@
         int lowestMatchIndex = change.matchIndex;
 
         AbstractToken<T> token;
-        int relexOffset = lexerInputOperation.lastTokenEndOffset(); // For 
debug purposes only
+        int relexOffset;
         while ((token = lexerInputOperation.nextToken()) != null) {
             // Get lookahead and state; Will certainly use them both since 
updater runs for inc token lists only
             int lookahead = lexerInputOperation.lookahead();
diff --git a/lexer/src/org/netbeans/lib/lexer/token/AbstractToken.java 
b/lexer/src/org/netbeans/lib/lexer/token/AbstractToken.java
--- a/lexer/src/org/netbeans/lib/lexer/token/AbstractToken.java
+++ b/lexer/src/org/netbeans/lib/lexer/token/AbstractToken.java
@@ -97,7 +97,7 @@
     
     AbstractToken(T id, int rawOffset) {
         this.id = id;
-        this.rawOffset = rawOffset;
+        setRawOffset(rawOffset);
     }
     
     /**
@@ -139,6 +139,9 @@
      * @param rawOffset new raw offset.
      */
     public final void setRawOffset(int rawOffset) {
+//        if (rawOffset < -1) { // -1 is default value
+//            throw new IllegalArgumentException("Invalid rawOffset=" + 
rawOffset);
+//        }
         this.rawOffset = rawOffset;
     }
 
diff --git a/lexer/src/org/netbeans/lib/lexer/token/TextToken.java 
b/lexer/src/org/netbeans/lib/lexer/token/TextToken.java
--- a/lexer/src/org/netbeans/lib/lexer/token/TextToken.java
+++ b/lexer/src/org/netbeans/lib/lexer/token/TextToken.java
@@ -111,6 +111,7 @@
     public AbstractToken<T> markNoDefaultEmbedding() {
         CustomTextToken<T> token = new CustomTextToken<T>(id(), text, 
text.length());
         token.setTokenList(tokenList);
+        token.setRawOffset(rawOffset);
         AbstractToken<T> t = token.markNoDefaultEmbedding();
         assert (t == null);
         return token;

[hg] main-silver: #237479 - java.lang.IndexOutOfBoundsException:...

Miloslav Metelka 11/12/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