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.nio.charset.StandardCharsets; | |
import java.security.MessageDigest; | |
import java.util.UUID; | |
public class MRNToUUID { | |
public static UUID createUUIDFromMRN(String mrn) throws Exception { | |
// Normalize the MRN | |
String normMRN = mrn.toLowerCase(); | |
// Hash the MRN using SHA-256 |
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 LookupUsage { | |
public static void main(String[] args) throws IOException { | |
record Entry(ClassModel cm, MethodModel mm) {} | |
Map<Integer, List<Entry>> hits = new HashMap<>(); | |
Path javaBasePath = FileSystems.getFileSystem(java.net.URI.create("jrt:/")).getPath("/modules/java.base/java/"); | |
Files.walk(javaBasePath).filter(path -> path.toString().endsWith(".class")).forEach(classFile -> { | |
try { | |
ClassModel cm = ClassFile.of().parse(classFile); | |
if (cm.flags().has(AccessFlag.PUBLIC)) { |
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 static org.objectweb.asm.Opcodes.ACC_BRIDGE; | |
import static org.objectweb.asm.Opcodes.ACC_FINAL; | |
import static org.objectweb.asm.Opcodes.ACC_PUBLIC; | |
import static org.objectweb.asm.Opcodes.ACC_STATIC; | |
import static org.objectweb.asm.Opcodes.ACC_SUPER; | |
import static org.objectweb.asm.Opcodes.ACC_SYNTHETIC; | |
import static org.objectweb.asm.Opcodes.ALOAD; | |
import static org.objectweb.asm.Opcodes.ARETURN; | |
import static org.objectweb.asm.Opcodes.INVOKESPECIAL; |
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 StaticJava { | |
// Can only be created at build-time for static java | |
sealed interface RuntimeLocal<T> permits InternalRuntimeLocal { | |
// VM could knwo about this and optimize invocations | |
T get(); | |
static <T> RuntimeLocal<T> of(Supplier<T> supplier) {} | |
static <T> RuntimeLocal<T> ofLazy(Supplier<T> supplier) {} | |
} |
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 FooBar { | |
static Boolean tmpVal; | |
public static void main(String[] args) { | |
tmpVal = true; // readFromConfig | |
// Assuming config is initialized before method is called | |
foo(); | |
} |
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
werwrwerwerwerertertertsdfsdfsdf232423 |
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 TestClass { | |
// So assumming internal classes are closed of with Java 16 | |
// For Java [9;15] | |
// This will work because all packages are open to the unnamed module (stuff on the classpath) | |
// It will print a warning because you use method.setAccessible on a class in a package that will | |
// be closed of in Java 16 | |
public static void main1(String[] args) throws Exception { | |
Module unnamed = TestClass.class.getModule(); |
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 FilterMapToDoubleSortedSum extends Processor { | |
public Object process(int[] arr, TerminalQueryOperationNode node) { | |
// Original Query: C_FILTER->C_MAP_TO_DOUBLE->C_SORTED_NATURAL->CT_MATH_SUM | |
// Simplified : C_FILTER->C_MAP_TO_DOUBLE->CT_MATH_SUM | |
// Extract all functions from a linked list of query objects | |
SI_MapToDouble on = (SI_MapToDouble) node.previous().previous(); | |
IntToDoubleFunction mapper = on.getMapper(); | |
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
/** | |
* Lazily associate a computed value with a lookup object much like {@link ClassValue} but for {@link Lookup} objects. | |
*/ | |
public abstract class LookupValue<T> { | |
/** The cache of values. */ | |
private final ClassValue<ConcurrentHashMap<Integer, T>> LOOKUP_CACHE = new ClassValue<>() { | |
/** {@inheritDoc} */ | |
@Override |
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 static String toString(int[] a) { | |
int iMax = a.length - 1; | |
if (iMax == -1) | |
return "[]"; | |
int size = 2 * a.length; | |
for (int j = 0; j < a.length; j++) { | |
size += stringSize(a[j]); | |
} |
NewerOlder