From faffe6742d4e30cd0485f46abc40007af037c0b5 Mon Sep 17 00:00:00 2001 From: Justinas Dabravolskas Date: Sun, 8 Dec 2024 08:30:55 -0500 Subject: [PATCH] Reproducer for https://github.com/raphw/byte-buddy/issues/1732 --- .gitattributes | 12 +++++++++ .gitignore | 5 ++++ README.md | 1 + app/build.gradle | 35 ++++++++++++++++++++++++++ app/src/main/java/org/example/App.java | 23 +++++++++++++++++ gradle.properties | 5 ++++ 6 files changed, 81 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 README.md create mode 100644 app/build.gradle create mode 100644 app/src/main/java/org/example/App.java create mode 100644 gradle.properties diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f91f646 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf + +# These are Windows script files and should use crlf +*.bat text eol=crlf + +# Binary files should be left untouched +*.jar binary + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1b6985c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build diff --git a/README.md b/README.md new file mode 100644 index 0000000..52e2c72 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# jit-broken-switch-example diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..360b463 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,35 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This generated file contains a sample Java application project to get you started. + * For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.11.1/userguide/building_java_projects.html in the Gradle documentation. + */ + +plugins { + // Apply the application plugin to add support for building a CLI application in Java. + id 'application' +} + +repositories { + // Use Maven Central for resolving dependencies. + mavenCentral() +} + +dependencies { + implementation 'net.bytebuddy:byte-buddy:1.15.10' +} + +// Apply a specific Java toolchain to ease working on different environments. +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +application { + // Define the main class for the application. + mainClass = 'org.example.App' + applicationDefaultJvmArgs = [ + '-Xcomp', + ] +} diff --git a/app/src/main/java/org/example/App.java b/app/src/main/java/org/example/App.java new file mode 100644 index 0000000..5ace58f --- /dev/null +++ b/app/src/main/java/org/example/App.java @@ -0,0 +1,23 @@ +package org.example; +import com.sun.tools.attach.VirtualMachine; +import net.bytebuddy.dynamic.scaffold.TypeValidation; +import net.bytebuddy.*; +import net.bytebuddy.dynamic.*; +public class App { + + private static final int POOL_NORMAL = 0; + private static final int POOL_SUSPENDED = 1; + private static final int POOL_SHUTDOWN = 2; + + public volatile int poolState; + + public static void main(String[] args) { + System.out.println("Running on:"+System.getProperty("java.version")); + DynamicType.Builder builder = new ByteBuddy().with(TypeValidation.ENABLED) + .redefine(App.class) + .name(App.class.getName() + "_Redefine"); + for (int i = 0; i < 100; i++) { + builder.make(); + } + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..377538c --- /dev/null +++ b/gradle.properties @@ -0,0 +1,5 @@ +# This file was generated by the Gradle 'init' task. +# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties + +org.gradle.configuration-cache=true +