Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8263910: Java.extend throws java.lang.ClassFormatError #13

Merged
merged 3 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import static org.openjdk.nashorn.internal.codegen.CompilerConstants.interfaceCallNoLookup;
import static org.openjdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup;
import static org.openjdk.nashorn.internal.lookup.Lookup.MH;
import static org.openjdk.nashorn.internal.runtime.linker.AdaptationResult.Outcome.ERROR_NO_ACCESSIBLE_CONSTRUCTOR;

import java.lang.annotation.Annotation;
import java.lang.invoke.CallSite;
Expand Down Expand Up @@ -73,7 +72,6 @@
import org.openjdk.nashorn.internal.codegen.CompilerConstants.Call;
import org.openjdk.nashorn.internal.runtime.ScriptFunction;
import org.openjdk.nashorn.internal.runtime.ScriptObject;
import org.openjdk.nashorn.internal.runtime.linker.AdaptationResult.Outcome;

/**
* Generates bytecode for a Java adapter class. Used by the {@link JavaAdapterFactory}.
Expand Down Expand Up @@ -249,10 +247,9 @@ final class JavaAdapterBytecodeGenerator {
* @param commonLoader the class loader that can see all of superClass, interfaces, and Nashorn classes.
* @param classOverride true to generate the bytecode for the adapter that has class-level overrides, false to
* generate the bytecode for the adapter that has instance-level overrides.
* @throws AdaptationException if the adapter can not be generated for some reason.
*/
JavaAdapterBytecodeGenerator(final Class<?> superClass, final List<Class<?>> interfaces,
final ClassLoader commonLoader, final boolean classOverride) throws AdaptationException {
final ClassLoader commonLoader, final boolean classOverride) {
assert superClass != null && !superClass.isInterface();
assert interfaces != null;

Expand Down Expand Up @@ -383,7 +380,7 @@ private void emitInitCallThis(final InstructionAdapter mv) {
}
}

private boolean generateConstructors() throws AdaptationException {
private boolean generateConstructors() {
boolean gotCtor = false;
boolean canBeAutoConverted = false;
for (final Constructor<?> ctor: superClass.getDeclaredConstructors()) {
Expand All @@ -394,7 +391,8 @@ private boolean generateConstructors() throws AdaptationException {
}
}
if(!gotCtor) {
throw new AdaptationException(ERROR_NO_ACCESSIBLE_CONSTRUCTOR, superClass.getCanonicalName());
throw JavaAdapterFactory.adaptationException(
JavaAdapterFactory.ErrorOutcome.NO_ACCESSIBLE_CONSTRUCTOR, superClass.getCanonicalName());
}
return canBeAutoConverted;
}
Expand All @@ -407,9 +405,9 @@ private boolean generateConstructors(final Constructor<?> ctor) {
return false;
}

// Generate a constructor that delegates to ctor, but takes an additional ScriptObject parameter at the
// beginning of its parameter list.
generateOverridingConstructor(ctor, false);
// Generate a constructor that delegates to ctor, but takes an additional ScriptObject parameter at the
// beginning of its parameter list.
generateOverridingConstructor(ctor, false);

if (samName == null) {
return false;
Expand Down Expand Up @@ -1123,7 +1121,7 @@ private static int getAccessModifiers(final Method method) {
* class.
* @param type the type defining the methods.
*/
private void gatherMethods(final Class<?> type) throws AdaptationException {
private void gatherMethods(final Class<?> type) {
if (Modifier.isPublic(type.getModifiers())) {
final Method[] typeMethods = type.isInterface() ? type.getMethods() : type.getDeclaredMethods();

Expand All @@ -1143,7 +1141,8 @@ private void gatherMethods(final Class<?> type) throws AdaptationException {
hasExplicitFinalizer = true;
if(Modifier.isFinal(m)) {
// Must be able to override an explicit finalizer
throw new AdaptationException(Outcome.ERROR_FINAL_FINALIZER, type.getCanonicalName());
throw JavaAdapterFactory.adaptationException(
JavaAdapterFactory.ErrorOutcome.FINAL_FINALIZER, type.getCanonicalName());
}
}
continue;
Expand Down Expand Up @@ -1174,7 +1173,7 @@ private void gatherMethods(final Class<?> type) throws AdaptationException {
}
}

private void gatherMethods(final List<Class<?>> classes) throws AdaptationException {
private void gatherMethods(final List<Class<?>> classes) {
for(final Class<?> c: classes) {
gatherMethods(c);
}
Expand Down
Loading