Skip to content

Commit

Permalink
8332505: JEP 457: ClassRemapper forgets to remap bootstrap method ref…
Browse files Browse the repository at this point in the history
…erences

Reviewed-by: jlahoda
  • Loading branch information
asotona committed May 28, 2024
1 parent cabe337 commit aa4c83a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, 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 Down Expand Up @@ -239,7 +239,7 @@ public CodeTransform asCodeTransform() {
ii.isInterface());
case InvokeDynamicInstruction idi ->
cob.invokedynamic(DynamicCallSiteDesc.of(
idi.bootstrapMethod(), idi.name().stringValue(),
mapDirectMethodHandle(idi.bootstrapMethod()), idi.name().stringValue(),
mapMethodDesc(idi.typeSymbol()),
idi.bootstrapArgs().stream().map(this::mapConstantValue).toArray(ConstantDesc[]::new)));
case NewObjectInstruction c ->
Expand Down
10 changes: 7 additions & 3 deletions test/jdk/jdk/classfile/AdvancedTransformationsTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, 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,6 +24,7 @@
/*
* @test
* @summary Testing ClassFile advanced transformations.
* @bug 8332505
* @run junit AdvancedTransformationsTest
*/
import helpers.ByteArrayClassLoader;
Expand Down Expand Up @@ -65,6 +66,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.runtime.ObjectMethods;
import java.util.ArrayDeque;
import jdk.internal.classfile.impl.AbstractPseudoInstruction;

Expand Down Expand Up @@ -187,9 +189,10 @@ void testRemapDetails() throws Exception {
var fooAnno = ClassDesc.ofDescriptor(FooAnno.class.descriptorString());
var barAnno = ClassDesc.ofDescriptor(BarAnno.class.descriptorString());
var rec = ClassDesc.ofDescriptor(Rec.class.descriptorString());
var objectMethods = ClassDesc.ofDescriptor(ObjectMethods.class.descriptorString());
var cc = ClassFile.of();
var remapped = cc.parse(
ClassRemapper.of(Map.of(foo, bar, fooAnno, barAnno)).remapClass(
ClassRemapper.of(Map.of(foo, bar, fooAnno, barAnno, objectMethods, bar)).remapClass(
cc,
cc.parse(
Rec.class.getResourceAsStream(Rec.class.getName() + ".class")
Expand All @@ -211,7 +214,8 @@ void testRemapDetails() throws Exception {
"PUTSTATIC, owner: AdvancedTransformationsTest$Bar, field name: fooField, field type: LAdvancedTransformationsTest$Bar;",
"INVOKESTATIC, owner: AdvancedTransformationsTest$Bar, method name: fooMethod, method type: (LAdvancedTransformationsTest$Bar;)LAdvancedTransformationsTest$Bar",
"method type: ()LAdvancedTransformationsTest$Bar;",
"GETFIELD, owner: AdvancedTransformationsTest$Rec, field name: foo, field type: LAdvancedTransformationsTest$Bar;");
"GETFIELD, owner: AdvancedTransformationsTest$Rec, field name: foo, field type: LAdvancedTransformationsTest$Bar;",
"bootstrap method: STATIC AdvancedTransformationsTest$Bar::bootstrap");
assertFalse(out.contains("bootstrap method arguments indexes: []"), "bootstrap arguments lost");
}

Expand Down

1 comment on commit aa4c83a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.