diff options
author | Stephan Herrmann | 2016-06-23 16:18:07 +0000 |
---|---|---|
committer | Stephan Herrmann | 2016-06-23 16:18:07 +0000 |
commit | f81bc1b2873c68ded035af6f4704351228da24c6 (patch) | |
tree | 4837fea6b2f0874a72cb771d8ee9870044d8e5bc | |
parent | 2e778383fc817293f8f61fe7d29c461583f84578 (diff) | |
download | eclipse.jdt.core-f81bc1b2873c68ded035af6f4704351228da24c6.tar.gz eclipse.jdt.core-f81bc1b2873c68ded035af6f4704351228da24c6.tar.xz eclipse.jdt.core-f81bc1b2873c68ded035af6f4704351228da24c6.zip |
Bug 496545: "Error retrieving proposed text" on certain generic
signature
Change-Id: I1148f36c8c8620af8ece08913b920cd81f4eecab
-rw-r--r-- | org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SignatureTests.java | 15 | ||||
-rw-r--r-- | org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java | 9 |
2 files changed, 19 insertions, 5 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SignatureTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SignatureTests.java index bc98f73b34..0e140192a1 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SignatureTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SignatureTests.java @@ -502,6 +502,21 @@ public void testGetReturnType2() { assertEquals("Signature#getReturnType is not correct", "+[I", Signature.getReturnType(methodSig)); } +public void testGetReturnType3() { + String methodSig = "(LObject;)+*"; + assertEquals("Signature#getReturnType is not correct", "+*", + Signature.getReturnType(methodSig)); +} +public void testGetReturnType4() { + String methodSig = "(LObject;)+["; // too short + try { + Signature.getReturnType(methodSig); + } catch (IllegalArgumentException iae) { + // OK + return; + } + fail("Expected exception not raised"); +} /** * @see Signature */ diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java index dcaad7b43a..bbf5149962 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java @@ -1461,17 +1461,16 @@ public class Util implements SuffixConstants { return start; case C_SUPER : case C_EXTENDS : - // need a minimum 3 chars "+[I" - if (start >= string.length - 2) { - throw new IllegalArgumentException(); - } break; default : // must start in "+/-" - throw new IllegalArgumentException(); + throw new IllegalArgumentException(); } c = string[++start]; + if (c != C_STAR && start >= string.length -1) { // unless "-*" we need at least one more char, e.g. after "+[", other variants are even longer + throw new IllegalArgumentException(); + } switch (c) { case C_CAPTURE : return scanCaptureTypeSignature(string, start); |