Skip to content

Instantly share code, notes, and snippets.

View raphw's full-sized avatar

Rafael Winterhalter raphw

View GitHub Profile
@raphw
raphw / Foo.java
Last active January 19, 2016 14:45
Illegal receiver type specification: Annotate type path.
class Foo {
class Bar {
void qux(@TypeAnnotation Foo.@TypeAnnotation Bar this) { } // Foo is treated as owner type.
}
}
@Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
@interface TypeAnnotation { }
@raphw
raphw / Foo.java
Last active January 19, 2016 13:22
Receiver type overview
public class Foo<T> {
class Bar<S> {
Bar(Foo<T> Foo.this) {}
void bar(Foo<T>.Bar<S> this) {}
}
static class Qux<S> {
@raphw
raphw / Foo.java
Created January 12, 2016 15:26
A receiver type is not resolved as a parameterized type.
public class Foo<T> {
void foo(Foo<@Bar T> this) {}
public static void main(String[] args) {
assert Foo.class.getDeclaredMethod("foo").getAnnotatedReceiverType() instanceof AnnotatedParameterizedType;
}
}
@raphw
raphw / Foo.java
Created January 12, 2016 00:24
Type annotations on parameters of multiple type variable bound types are not filtered to their respective bound.
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.AnnotatedParameterizedType;
import java.util.List;
import java.util.concurrent.Callable;
public class Foo<T extends List<@Sample ?> & Callable<@Sample ?>> {
@raphw
raphw / Foo.java
Last active January 12, 2016 00:08
Impossible to read owner type of an annotated parameterized type.
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.AnnotatedParameterizedType;
public class Foo<T> {
@Sample(1) Foo<@Sample(2) Void>.@Sample(3) Bar<@Sample(4) Void> field;
@raphw
raphw / Foo.java
Last active January 11, 2016 23:42
Example of wrong type annotation indexing of type varaible bounds on recursive type variables by Java Core reflection
package net.bytebuddy.description;
import jdk.internal.org.objectweb.asm.TypeReference;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.List;
@raphw
raphw / bower.json
Created November 26, 2015 14:01
Simple Gulp script
{
"name": "app",
"version": "0.0.0",
"authors": [
"foo <[email protected]>"
],
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
@raphw
raphw / Interceptor.java
Created October 11, 2015 10:12
Example for bug report
package net.bytebuddy;
import net.bytebuddy.agent.ByteBuddyAgent;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.implementation.bind.annotation.Origin;
import net.bytebuddy.implementation.bind.annotation.RuntimeType;
import net.bytebuddy.matcher.ElementMatchers;
@raphw
raphw / Bar.java
Last active September 2, 2015 08:55
Package-private types in bridges.
package net.bytebuddy.bar;
public class Bar<T extends Baz> {
public void foo(T t) { }
}
@raphw
raphw / SealedQuirk.java
Last active August 29, 2015 14:27
Sealed package quirk.
public class SealedQuirk {
private static final String FOO = "foo", BAR = "bar", TMP = "tmp";
private ClassLoader singleClassLoader, sealedChildClassLoader, sealedParentClassLoader;
@Before
public void setUp() throws Exception {
File folder = Files.createTempDirectory(TMP).toFile();