Skip to content

Commit

Permalink
Merge pull request #26730 from KyleAure/fix-java-17-auto-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAure committed Oct 27, 2023
2 parents 6e89a1c + 8d14a79 commit e9a0849
Show file tree
Hide file tree
Showing 16 changed files with 599 additions and 106 deletions.
Expand Up @@ -202,7 +202,7 @@ private static boolean isTransformPossible(byte[] bytes) {
if (isJDK8WithHotReplaceBug)
return classFileVersion <= Opcodes.V1_7;
else
return classFileVersion <= Opcodes.V11;
return classFileVersion <= Opcodes.V22;
}

/**
Expand Down
@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.example.bytecode;

public class HelloWorldJava11 {
public static void printHi() {
System.out.println("hi");
}

public static int addThingsStatic(int a, int b) {
int c = a + b;
return c;
}

public int addThings(int a, int b) {
int c = a + b;
return c;
}

public Object instancer(Class blah) throws IllegalAccessException, InstantiationException {
return blah.newInstance();
}
}
@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.example.bytecode;

public class HelloWorldJava17 {
public static void printHi() {
System.out.println("hi");
}

public static int addThingsStatic(int a, int b) {
int c = a + b;
return c;
}

public int addThings(int a, int b) {
int c = a + b;
return c;
}

public Object instancer(Class blah) throws IllegalAccessException, InstantiationException {
return blah.newInstance();
}
}
@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.example.bytecode;

public class HelloWorldJava21 {
public static void printHi() {
System.out.println("hi");
}

public static int addThingsStatic(int a, int b) {
int c = a + b;
return c;
}

public int addThings(int a, int b) {
int c = a + b;
return c;
}

public Object instancer(Class blah) throws IllegalAccessException, InstantiationException {
return blah.newInstance();
}
}
@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.example.bytecode;

public class HelloWorldJava6 {
public static void printHi() {
System.out.println("hi");
}

public static int addThingsStatic(int a, int b) {
int c = a + b;
return c;
}

public int addThings(int a, int b) {
int c = a + b;
return c;
}

public Object instancer(Class blah) throws IllegalAccessException, InstantiationException {
return blah.newInstance();
}
}
@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.example.bytecode;

public class HelloWorldJava7 {
public static void printHi() {
System.out.println("hi");
}

public static int addThingsStatic(int a, int b) {
int c = a + b;
return c;
}

public int addThings(int a, int b) {
int c = a + b;
return c;
}

public Object instancer(Class blah) throws IllegalAccessException, InstantiationException {
return blah.newInstance();
}
}
@@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.example.bytecode;

public class HelloWorldJava7StaticInit {
public static final int staticint = 0;

static String someString = new String();

static {
System.out.println("HiStatic");
}

public static void printHi() {
System.out.println("hi");
}

public static int addThingsStatic(int a, int b) {
int c = a + b;
return c;
}

public int addThings(int a, int b) {
int c = a + b;
return c;
}

public Object instancer(Class blah) throws IllegalAccessException, InstantiationException {
return blah.newInstance();
}
}
@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.example.bytecode;

public class HelloWorldJava8 {
public static void printHi() {
System.out.println("hi");
}

public static int addThingsStatic(int a, int b) {
int c = a + b;
return c;
}

public int addThings(int a, int b) {
int c = a + b;
return c;
}

public Object instancer(Class blah) throws IllegalAccessException, InstantiationException {
return blah.newInstance();
}
}
@@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.example.bytecode;

import java.util.concurrent.Callable;

public class HelloWorldJava8Lambdas {
public static void printHi() {
System.out.println("hi");
}

public static int addThingsStatic(int a, int b) {
Callable<String> helloLambda = () -> "Hello";
int c = a + b;
return c;
}

public int addThings(int a, int b) {
int c = a + b;
return c;
}

public Object instancer(Class blah) throws IllegalAccessException, InstantiationException {
return blah.newInstance();
}
}
@@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.example.bytecode;

public class HelloWorldJava8StaticInit {
public static final int staticint = 0;

static String someString = new String();

static {
System.out.println("HiStatic");
}

public static void printHi() {
System.out.println("hi");
}

public static int addThingsStatic(int a, int b) {
int c = a + b;
return c;
}

public int addThings(int a, int b) {
int c = a + b;
return c;
}

public Object instancer(Class blah) throws IllegalAccessException, InstantiationException {
return blah.newInstance();
}
}
@@ -0,0 +1,47 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.example.bytecode;

import java.util.concurrent.Callable;

public class HelloWorldJava8StaticLambdas {
public static final Callable<String> helloLambda = () -> "Hello";

public static final Converter<String> STRING_CONVERTER;

public static void printHi() {
System.out.println("hi");
}

static {
STRING_CONVERTER = (v -> v);
}

public static int addThingsStatic(int a, int b) {
int c = a + b;
return c;
}

public int addThings(int a, int b) {
int c = a + b;
return c;
}

public Object instancer(Class blah) throws IllegalAccessException, InstantiationException {
return blah.newInstance();
}

public static interface Converter<T> {
T convert(String param1String);
}
}
@@ -0,0 +1,13 @@
## Source files

The classes in this directory are the source files for the .class files located in the `test data` directory.
If you are adding a new class to this directory you need to manually compile it at the java level it was written to be tested against.

### Generate new class files

```sh
cd com.ibm.ws.ras.instrument_test

# TODO Add JDK 11 to your path

javac -d "test/test data/" test/com/ibm/example/bytecode/HelloWorldJava11.java

0 comments on commit e9a0849

Please sign in to comment.