Skip to content

Instantly share code, notes, and snippets.

@burningtnt
burningtnt / VectorSupport.java
Last active May 4, 2025 06:41
Enable Vector API during runtime.
/*
* VectorSupport
* Copyright (c) 2025 Burning_TNT<[email protected]>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
import sun.misc.Unsafe;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
public final class TrustedLookupAccessor {
public static MethodHandles.Lookup get() throws Throwable {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
Unsafe U = (Unsafe) theUnsafe.get(null);

Note

为简化无关环节,部分细节可能会省去,而进一步的深入解释将标记在 NOTE 内。 如果这是您第一次了解 MethodHandle 和 VarHandle,可直接掠过这些部分。

Tip

本文将用 TIP 标记您需要使用刚刚学到的技能实践的部分。 边学边练,效果 ++。

零开销·反射

/*
* MethodHandleLinker
* Copyright (c) 2024 Burning_TNT<[email protected]>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@burningtnt
burningtnt / TrustedLookupAccessor.java
Last active May 1, 2025 14:08
Access IMPL_LOOKUP without Unsafe
import java.lang.foreign.*;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
public final class TrustedLookupAccessor {
private TrustedLookupAccessor() {
}
private static final MethodHandles.Lookup INSTANCE = null;
@burningtnt
burningtnt / 我到底该怎么提问.md
Last active August 10, 2024 10:58
我到底该怎么提问

本文节选自 learnku.com(其实这篇文章节选自 How To Ask Questions The Smart Way

首先,你应当明确……

我们痛恨把一个消息复制几百遍

当有人给你这篇文章的链接时,说明你违反了本文上的某条规则。 你应当仔细阅读,然后告诉他我违反了哪一条。

礼貌总是有益的

@burningtnt
burningtnt / Minecraft 崩溃常见回答预设.md
Last active June 9, 2025 16:41 — forked from zkitefly/炸师傅的常用句子.md
Minecraft 崩溃常见回答预设

HMCL 问题

// 日志

出现问题后不要退出启动器,在启动器的 设置 -- 通用 中导出启动器日志,然后把导出的文件发出来 https://img.kookapp.cn/assets/2023-01/oHQeKnzwWj0md0dr.png

// PR Collection

手动去 https://zkitefly.github.io/HMCL-Snapshot-Update/prs 下载新版本,放到原来 HMCL 旁边,然后用新版本 HMCL 再试一次