Skip to content

Commit

Permalink
8289561: java/lang/instrument/NativeMethodPrefixAgent.java fails with…
Browse files Browse the repository at this point in the history
… "ERROR: Injection failure: java.lang.UnsupportedOperationException: Records requires ASM8"

Reviewed-by: lmesnik, cjplummer, sspitsyn
  • Loading branch information
Alex Menkov committed Oct 7, 2022
1 parent a1747ef commit c1166a3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
15 changes: 12 additions & 3 deletions test/jdk/java/lang/instrument/NativeMethodPrefixAgent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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 @@ -45,6 +45,13 @@ class NativeMethodPrefixAgent {

static ClassFileTransformer t0, t1, t2;
static Instrumentation inst;
private static Throwable agentError;

public static void checkErrors() {
if (agentError != null) {
throw new RuntimeException("Agent error", agentError);
}
}

static class Tr implements ClassFileTransformer {
final String trname;
Expand Down Expand Up @@ -87,10 +94,12 @@ static class Tr implements ClassFileTransformer {

return redef? null : newcf;
} catch (Throwable ex) {
if (agentError == null) {
agentError = ex;
}
System.err.println("ERROR: Injection failure: " + ex);
ex.printStackTrace();
System.err.println("Returning bad class file, to cause test failure");
return new byte[0];
return null;
}
}
return null;
Expand Down
4 changes: 3 additions & 1 deletion test/jdk/java/lang/instrument/NativeMethodPrefixApp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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 @@ -48,6 +48,8 @@ public void run(String args[], PrintStream out) throws Exception {
RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean();
System.err.println(mxbean.getVmVendor());

NativeMethodPrefixAgent.checkErrors();

for (int i = 0; i < gotIt.length; ++i) {
if (!gotIt[i]) {
throw new Exception("ERROR: Missing callback for transform " + i);
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/lang/instrument/asmlib/Instrumentor.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, 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 @@ -124,7 +124,7 @@ public void visitCode() {
}

public synchronized Instrumentor addNativeMethodTrackingInjection(String prefix, Consumer<InstrHelper> injector) {
instrumentingVisitor = new ClassVisitor(Opcodes.ASM7, instrumentingVisitor) {
instrumentingVisitor = new ClassVisitor(Opcodes.ASM9, instrumentingVisitor) {
private final Set<Consumer<ClassVisitor>> wmGenerators = new HashSet<>();
private String className;

Expand Down

1 comment on commit c1166a3

@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.