Skip to content

Instantly share code, notes, and snippets.

Rafael Winterhalter raphw

Block or report user

Report or block raphw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Executable_Constructor.patch
Index: src/java.base/share/classes/java/lang/reflect/Executable.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java.base/share/classes/java/lang/reflect/Executable.java (revision 55752:8ae33203d600a7c9f9b2be9b31a0eb8197270ab1)
+++ src/java.base/share/classes/java/lang/reflect/Executable.java (revision 55752+:8ae33203d600+)
@@ -38,6 +38,7 @@
import sun.reflect.annotation.AnnotationSupport;
import sun.reflect.annotation.TypeAnnotationParser;
@raphw
raphw / TypeAnnotation.java
Last active Jul 22, 2019
Fix for JDK-8202469 and JDK-8202473
View TypeAnnotation.java
package sample;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
public @interface TypeAnnotation {
@raphw
raphw / NativeBinding.java
Created Jul 20, 2019
Example of a shadingproof JNI binding.
View NativeBinding.java
package com.shadeproof;
import net.bytebuddy.ByteBuddy;
public abstract class NativeBinding {
public static final NativeBinding INSTANCE;
static {
System.load("mylibrary");
@raphw
raphw / Bar.java
Created May 9, 2019
Class remapper ASM/Byte Buddy example
View Bar.java
package x;
public class Bar extends Foo {
@Override
public void m() {
System.out.println("bar");
}
}
@raphw
raphw / bridge_generic.sh
Last active Jan 22, 2019
Generation of a visibility bridge method.
View bridge_generic.sh
mkdir pkg1
echo "package pkg1; class SuperClass<X> { public X m() { return null; } }" > pkg1/SuperClass.java
echo "package pkg1; public class SubClass extends SuperClass<Void> { }" > pkg1/SubClass.java
${JAVA_HOME}/bin/javac pkg1/*.java
mkdir pkg2
echo "package pkg2; class Main { public static void main(String[] args) throws Exception { pkg1.SubClass.class.getMethod(\"m\").invoke(new pkg1.SubClass()); } }" > pkg2/Main.java
${JAVA_HOME}/bin/javac pkg2/*.java
${JAVA_HOME}/bin/java -cp . pkg2.Main
@raphw
raphw / bridge.sh
Created Jan 22, 2019
Generation of a visibility bridge method.
View bridge.sh
mkdir pkg1
echo "package pkg1; class SuperClass<X> { public X m() { return null; } }" > pkg1/SuperClass.java
echo "package pkg1; public class SubClass extends SuperClass<Void> { }" > pkg1/SubClass.java
${JAVA_HOME}/bin/javac pkg1/*.java
mkdir pkg2
echo "package pkg2; class Main { public static void main(String[] args) throws Exception { pkg1.SubClass.class.getMethod(\"m\").invoke(new pkg1.SubClass()); } }" > pkg2/Main.java
${JAVA_HOME}/bin/javac pkg2/*.java
${JAVA_HOME}/bin/java -cp . pkg2.Main
@raphw
raphw / ReactiveMain.java
Created Oct 22, 2018
A reactive stream processor
View ReactiveMain.java
import static org.asynchttpclient.Dsl.asyncHttpClient;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
@raphw
raphw / Experiment.class
Created Jun 2, 2018
Twist transformer order
View Experiment.class
package sun.instrument;
import net.bytebuddy.agent.ByteBuddyAgent;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.implementation.StubMethod;
import net.bytebuddy.implementation.bytecode.assign.Assigner;
import net.bytebuddy.utility.JavaModule;
View GenericNestedTypeDemo.java
public class GenericNestedType {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface SampleTypeAnnotation { }
static class GenericNested<T> {
class Inner { }
}
@raphw
raphw / BugReportDeprecatedModifier.java
Last active Apr 17, 2018
Demonstrating loosing the deprecated modifier with retransformation when two transformers are registered using an old Log4j (Java 1.1).
View BugReportDeprecatedModifier.java
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.util.TraceClassVisitor;
import java.io.PrintWriter;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;
import java.security.ProtectionDomain;
public class BugReportDeprecatedModifier {
You can’t perform that action at this time.