Skip to content

Instantly share code, notes, and snippets.

View XiaoPangxie732's full-sized avatar

XiaoPangxie732

View GitHub Profile
@XiaoPangxie732
XiaoPangxie732 / ImplLookupGetter.java
Created August 18, 2024 12:45
Get IMPL_LOOKUP using FFI via JNI
import java.lang.foreign.*;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.lang.reflect.Field;
public class ImplLookupGetter {
public static final MethodHandles.Lookup IMPL_LOOKUP;
public static final int JNI_VERSION_21 = 0x00150000;
@XiaoPangxie732
XiaoPangxie732 / InlineBenchmark.java
Created February 17, 2024 07:03
random benchmarks
@State(Scope.Thread)
@Warmup(iterations = 3)
@Measurement(iterations = 3)
@Fork(1)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class InlineBenchmark {
private Test test;
private static final MethodHandle HANDLE;
private static final Method METHOD;
@XiaoPangxie732
XiaoPangxie732 / ioutils.java
Last active April 16, 2022 19:33
things may be useful
public static byte[] readFileUsingFileChannelAndMappedByteBuffer(Path file) {
try(FileChannel ch = FileChannel.open(file, StandardOpenOption.READ)) {
MappedByteBuffer mbb = ch.map(FileChannel.MapMode.READ_ONLY, 0, ch.size());
byte[] bytes = new byte[mbb.remaining()];
mbb.get(bytes);
return bytes;
}
}
{
"homepage": "https://github.com/XiaoPangxie732/Flycycle",
"1.16.5": {
"0.1.0": "Base things"
},
"promos": {
"1.16.5-latest": "0.1.0",
"1.16.5-recommended": "0.1.0"
}
}