Skip to content
Closed
22 changes: 1 addition & 21 deletions test/hotspot/jtreg/runtime/linkResolver/InterfaceObj.jasm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,12 +26,6 @@
interface I { }

public class InterfaceObj implements I {
static void f(I intf) throws Throwable {
I.finalize();
}
public static void testFinalize() throws Throwable {
f(new InterfaceObj());
}
static void c(I intf) throws Throwable {
I.clone();
}
Expand All @@ -53,20 +47,6 @@ super public class InterfaceObj implements I version 60:0 {
return;
}

static Method f:"(LI;)V" throws java/lang/Throwable stack 1 locals 1 {
aload_0;
invokeinterface InterfaceMethod I.finalize:"()V", 1;
return;
}

public static Method testFinalize:"()V" throws java/lang/Throwable stack 2 locals 1 {
new class InterfaceObj;
dup;
invokespecial Method "<init>":"()V";
invokestatic Method f:"(LI;)V";
return;
}

static Method c:"(LI;)V" throws java/lang/Throwable stack 1 locals 1 {
aload_0;
invokeinterface InterfaceMethod I.clone:"()Ljava/lang/Object;", 1;
Expand Down
27 changes: 4 additions & 23 deletions test/hotspot/jtreg/runtime/linkResolver/InterfaceObjectTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,13 +24,12 @@
/*
* @test
* @bug 8026394 8251414
* @summary test interface resolution when clone and finalize are declared abstract within
* @summary test interface resolution when clone is declared abstract within
* an interface and when they are not
* @compile InterfaceObj.jasm
* @run main InterfaceObjectTest
*/
interface IClone extends Cloneable {
void finalize() throws Throwable;
Object clone();
}

Expand All @@ -43,41 +42,23 @@ public Object clone() {
return null;
}

public void finalize() throws Throwable {
try {
System.out.println("In InterfaceObjectTest's finalize() method\n");
} catch (Throwable t) {
throw new AssertionError(t);
}
}

public static void tryIt(ICloneExtend o1) {
try {
Object o2 = o1.clone();
o1.finalize();
} catch (Throwable t) {
throw new AssertionError(t);
}
}


public static void main(String[] args) throws Exception {
// Test with abstract public clone() and finalize() methods.
// Test with abstract public clone() method.
InterfaceObjectTest o1 = new InterfaceObjectTest();
tryIt(o1);


// Test with reflection without abstract public clone() and finalize() methods.
// Test with reflection without abstract public clone() method.
Class cls = Class.forName("InterfaceObj");
try {
java.lang.reflect.Method m = cls.getMethod("testFinalize");
m.invoke(cls);
throw new RuntimeException("Failed to throw NoSuchMethodError for finalize()");
} catch (java.lang.reflect.InvocationTargetException e) {
if (!e.getCause().toString().contains("NoSuchMethodError")) {
throw new RuntimeException("wrong ITE: " + e.getCause().toString());
}
}

try {
java.lang.reflect.Method m = cls.getMethod("testClone");
Expand Down