This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.reflect.Member; | |
/** | |
* @author peter.lawrey | |
*/ | |
@Retention(RetentionPolicy.RUNTIME) | |
public @interface CustomAnnotation { | |
public int value() default 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Member; | |
/** | |
* @author peter.lawrey | |
*/ | |
public interface AnnotationHandler<A> { | |
void process(Model model, Member member, A annotation); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class A { | |
public interface B { | |
public enum C {; | |
public @interface D { | |
public class E { | |
// etc etc | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Field; | |
class MainClass { | |
// requires Java 7 update 5+ | |
static { | |
try { | |
Field value = String.class.getDeclaredField("value"); | |
value.setAccessible(true); | |
value.set("B", value.get("ABC")); | |
} catch (Throwable e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.higherfrequencytrading.chronicle.example; | |
import com.higherfrequencytrading.chronicle.Chronicle; | |
import com.higherfrequencytrading.chronicle.Excerpt; | |
import com.higherfrequencytrading.chronicle.impl.IndexedChronicle; | |
import com.higherfrequencytrading.chronicle.tools.ChronicleTools; | |
/** | |
* @author Julien Eluard | |
* @author peter.lawrey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java (revision 9f6a0e678ebfed5aa8d636886fae35be1cca092f) | |
+++ src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java (revision ) | |
@@ -118,7 +118,7 @@ | |
for (l = 0; l < achunksection.length; ++l) { | |
if (achunksection[l] != null && (!flag || !achunksection[l].isEmpty()) && (i & 1 << l) != 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
Stream.of(Boolean.class, Byte.class, Character.class, Short.class, Integer.class, | |
Long.class, Float.class, Double.class, Void.class).map(c -> { | |
try { | |
return c.getField("TYPE").get(null); | |
} catch (Exception e) { | |
throw new AssertionError(e); | |
} | |
}).forEach(System.out::println); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
In Java 8 this program prints | |
java.lang.Throwable | |
at A.printStackTrace(A.java:8) | |
at A.<clinit>(A.java:5) | |
at java.lang.Class.forName0(Native Method) | |
Note: <clinit> is the static initializer method for interface A | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PingPongMain { | |
public static void main(String[] args) throws InterruptedException { | |
new Thread(() -> { | |
try { | |
synchronized ("bb") { | |
while (true) { | |
"bb".wait(); | |
"bb".notifyAll(); | |
System.out.println("b"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MemoryCopy { | |
private static final Unsafe UNSAFE; | |
static { | |
Unsafe unsafe = null; | |
try { | |
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); | |
theUnsafe.setAccessible(true); | |
unsafe = (Unsafe) theUnsafe.get(null); | |
} catch (Exception ex) { |
OlderNewer