Bug 520180 - [9] Evaluation throws "String index out of range: -1" with
JRE 9
Change-Id: I240471cef3d7796a5497956e798275778b91f096
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/SourceBasedSourceGenerator.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/SourceBasedSourceGenerator.java
index 72bca4e..5a65c6b 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/SourceBasedSourceGenerator.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/SourceBasedSourceGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -193,10 +193,19 @@
fCodeSnippet = codeSnippet;
fCreateInAStaticMethod = createInAStaticMethod;
int index = sourceLevel.indexOf('.');
- String num = sourceLevel.substring(0, index);
+ String num;
+ if (index != -1) {
+ num = sourceLevel.substring(0, index);
+ } else {
+ num = sourceLevel;
+ }
fSourceMajorLevel = Integer.valueOf(num).intValue();
- num = sourceLevel.substring(index + 1);
- fSourceMinorLevel = Integer.valueOf(num).intValue();
+ if (index != -1) {
+ num = sourceLevel.substring(index + 1);
+ fSourceMinorLevel = Integer.valueOf(num).intValue();
+ } else {
+ fSourceMinorLevel = 0;
+ }
}
/**
@@ -265,7 +274,9 @@
buffer.append(' ');
buffer.append(fLocalVariableNames[i]);
if (i + 1 < length)
+ {
buffer.append(", "); //$NON-NLS-1$
+ }
}
buffer.append(") throws Throwable {"); //$NON-NLS-1$
buffer.append('\n');