8163553: java.lang.LinkageError from test java/lang/ThreadGroup/Stop.java

Reviewed-by: redestad
This commit is contained in:
Paul Sandoz 2016-11-01 17:20:45 -07:00
parent f22ecd235a
commit ff33d165a6
7 changed files with 30 additions and 25 deletions

View File

@ -80,7 +80,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
default : throw newInternalError("unexpected xtype: " + xtype);
}
} catch (Throwable t) {
throw newInternalError(t);
throw uncaughtException(t);
}
}
@ -188,7 +188,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
case D_TYPE: return (double) speciesData().getters[i].invokeBasic(this);
}
} catch (Throwable ex) {
throw newInternalError(ex);
throw uncaughtException(ex);
}
throw new InternalError("unexpected type: " + speciesData().typeChars+"."+i);
}
@ -408,18 +408,14 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
*/
static boolean speciesDataCachePopulated() {
Class<BoundMethodHandle> rootCls = BoundMethodHandle.class;
try {
for (Class<?> c : rootCls.getDeclaredClasses()) {
if (rootCls.isAssignableFrom(c)) {
final Class<? extends BoundMethodHandle> cbmh = c.asSubclass(BoundMethodHandle.class);
SpeciesData d = Factory.getSpeciesDataFromConcreteBMHClass(cbmh);
assert(d != null) : cbmh.getName();
assert(d.clazz == cbmh);
assert(CACHE.get(d.typeChars) == d);
}
for (Class<?> c : rootCls.getDeclaredClasses()) {
if (rootCls.isAssignableFrom(c)) {
final Class<? extends BoundMethodHandle> cbmh = c.asSubclass(BoundMethodHandle.class);
SpeciesData d = Factory.getSpeciesDataFromConcreteBMHClass(cbmh);
assert(d != null) : cbmh.getName();
assert(d.clazz == cbmh);
assert(CACHE.get(d.typeChars) == d);
}
} catch (Throwable e) {
throw newInternalError(e);
}
return true;
}

View File

@ -1021,7 +1021,7 @@ class InvokerBytecodeGenerator {
try {
emptyArray = name.function.resolvedHandle().invoke();
} catch (Throwable ex) {
throw newInternalError(ex);
throw uncaughtException(ex);
}
assert(java.lang.reflect.Array.getLength(emptyArray) == 0);
assert(emptyArray.getClass() == rtype); // exact typing

View File

@ -855,7 +855,11 @@ class LambdaForm {
System.out.println("LambdaForm compilation failed: " + this);
bge.printStackTrace(System.out);
}
} catch (Error | Exception e) {
} catch (Error e) {
// Pass through any error
throw e;
} catch (Exception e) {
// Wrap any exception
throw newInternalError(this.toString(), e);
}
}

View File

@ -957,7 +957,7 @@ assertEquals("[A, B, C]", (String) caToString2.invokeExact('A', "BC".toCharArray
if (!fail) return needType;
// elicit an error:
this.asType(needType);
throw newInternalError("should not return", null);
throw newInternalError("should not return");
}
private void spreadArrayChecks(Class<?> arrayType, int arrayLength) {

View File

@ -379,11 +379,13 @@ class MethodHandleNatives {
name, fixMethodType(callerClass, type), appendixResult);
}
}
} catch (Error e) {
// Pass through an Error, including say StackOverflowError or
// OutOfMemoryError
throw e;
} catch (Throwable ex) {
if (ex instanceof LinkageError)
throw (LinkageError) ex;
else
throw new LinkageError(ex.getMessage(), ex);
// Wrap anything else in LinkageError
throw new LinkageError(ex.getMessage(), ex);
}
throw new LinkageError("no such method "+defc.getName()+"."+name+type);
}

View File

@ -107,10 +107,10 @@ import java.util.Properties;
/*non-public*/ static InternalError newInternalError(String message) {
return new InternalError(message);
}
/*non-public*/ static InternalError newInternalError(String message, Throwable cause) {
/*non-public*/ static InternalError newInternalError(String message, Exception cause) {
return new InternalError(message, cause);
}
/*non-public*/ static InternalError newInternalError(Throwable cause) {
/*non-public*/ static InternalError newInternalError(Exception cause) {
return new InternalError(cause);
}
/*non-public*/ static RuntimeException newIllegalStateException(String message) {
@ -132,7 +132,7 @@ import java.util.Properties;
/*non-public*/ static Error uncaughtException(Throwable ex) {
if (ex instanceof Error) throw (Error) ex;
if (ex instanceof RuntimeException) throw (RuntimeException) ex;
throw newInternalError("uncaught exception", ex);
throw new InternalError("uncaught exception", ex);
}
private static String message(String message, Object obj) {
if (obj != null) message = message + ": " + obj;

View File

@ -723,6 +723,9 @@ public final class StringConcatFactory {
default:
throw new StringConcatException("Concatenation strategy " + STRATEGY + " is not implemented");
}
} catch (Error | StringConcatException e) {
// Pass through any error or existing StringConcatException
throw e;
} catch (Throwable t) {
throw new StringConcatException("Generator failed", t);
}
@ -1092,9 +1095,9 @@ public final class StringConcatFactory {
UNSAFE.ensureClassInitialized(innerClass);
dumpIfEnabled(innerClass.getName(), classBytes);
return Lookup.IMPL_LOOKUP.findStatic(innerClass, METHOD_NAME, args);
} catch (Throwable e) {
} catch (Exception e) {
dumpIfEnabled(className + "$$FAILED", classBytes);
throw new StringConcatException("Error while spinning the class", e);
throw new StringConcatException("Exception while spinning the class", e);
}
}