This file contains hidden or 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.util.*; | |
@SuppressWarnings("ALL") | |
class Test { | |
static class ReifiedList<T> extends AbstractList<T> { | |
private final List<T> delegate = new ArrayList<>(); | |
private final Class<?> type; | |
@SafeVarargs | |
ReifiedList(@Deprecated T... unused) { |
This file contains hidden or 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.*; | |
import java.lang.reflect.*; | |
import java.util.Arrays; | |
enum MyEnum { | |
A(0.0, 0, ""); | |
MyEnum(@Foo("double annotated") double d, | |
int i, | |
@Foo("string annotated") String s) { } |
This file contains hidden or 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.util.Arrays; | |
import java.util.List; | |
import java.util.Spliterator; | |
import java.util.Spliterators; | |
import java.util.function.BiFunction; | |
import java.util.function.Consumer; | |
import java.util.stream.Stream; | |
import java.util.stream.StreamSupport; | |
public class PairMapSample { |
This file contains hidden or 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.*; | |
import java.lang.reflect.*; | |
@Retention(RetentionPolicy.RUNTIME) | |
@Target(ElementType.TYPE_USE) | |
@interface TA { | |
int value(); | |
} | |
public class MyClass { |
This file contains hidden or 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.com.example; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.BenchmarkMode; | |
import org.openjdk.jmh.annotations.CompilerControl; | |
import org.openjdk.jmh.annotations.Fork; | |
import org.openjdk.jmh.annotations.Measurement; | |
import org.openjdk.jmh.annotations.Mode; | |
import org.openjdk.jmh.annotations.OutputTimeUnit; | |
import org.openjdk.jmh.annotations.Param; |
This file contains hidden or 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.util.Collection; | |
import java.util.Comparator; | |
import java.util.PriorityQueue; | |
import java.util.SortedSet; | |
import java.util.TreeSet; | |
import java.util.concurrent.PriorityBlockingQueue; | |
public class WhoInheritsComparator { | |
public static void main(String[] args) { | |
SortedSet<Integer> c1 = new TreeSet<>(Comparator.reverseOrder()); |
This file contains hidden or 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.util.*; | |
class BreakHashSet { | |
public static void main(String[] args) { | |
Point[] points = new Point[20]; | |
Arrays.setAll(points, idx -> new Point(idx * 500_000_000, | |
-new Point(idx * 500_000_000, 0).hashCode())); | |
Set<Point> set = new HashSet<>(Arrays.asList(points)); | |
set.remove(points[1]); | |
System.out.println(set.contains(points[14])); // Prints false! |
This file contains hidden or 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.util.*; | |
import java.util.stream.*; | |
public class StringBuilderInHashMap { | |
public static void main(String[] args) { | |
List<StringBuilder> list = Stream.generate(() -> { | |
while (true) { | |
StringBuilder sb = new StringBuilder("a"); | |
int hc = sb.hashCode(); | |
if (((hc ^ (hc >>> 16)) & 0x3F) == 0) { |
This file contains hidden or 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 Circle { | |
public static void main(String[] args) { | |
// Preparation | |
int radius = Integer.parseInt(args[0]); | |
int rasterSize = radius * 2 + 1; | |
boolean[][] raster = new boolean[rasterSize][rasterSize]; | |
// Bresenham algorithm | |
int y = radius; | |
int err = radius; |
This file contains hidden or 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
diff --git a/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java b/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java | |
--- a/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java (revision 57611b30219191160f7faccb811b41a31c25c0b8) | |
+++ b/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java (date 1626887157914) | |
@@ -315,6 +315,18 @@ | |
return generateInnerClass(); | |
} | |
+ private static StackTraceElement getCallerFrame() { | |
+ StackTraceElement[] trace = new Exception().getStackTrace(); | |
+ for (int i = 0; i < trace.length - 1; i++) { |