import java.lang.classfile.*;
import java.lang.constant.*;
import java.nio.file.*;

import static java.lang.classfile.ClassFile.*;
import static java.lang.constant.ConstantDescs.*;

public class Sick {
	public static void main(String... args) throws Throwable {
		var cf = ClassFile.of();
		var cd = ClassDesc.of("Test");
		cf.buildTo(Path.of("Test.class"), cd, clb -> {
			MethodTypeDesc bsmType = MethodTypeDesc.of(CD_double, CD_MethodHandles_Lookup, CD_String, CD_Class);
			var cp = clb.constantPool();
			for (int i = 200; i < 600; i++) {
				cp.intEntry(i);
			}
			clb.withMethodBody("main", MethodTypeDesc.of(CD_void, CD_String.arrayType()), ACC_PUBLIC | ACC_STATIC, cob -> {
				cob.getstatic(ClassDesc.of("java.lang.System"), "out", ClassDesc.of("java.io.PrintStream"));
				cob.ldc(DynamicConstantDesc.of(MethodHandleDesc.ofMethod(DirectMethodHandleDesc.Kind.STATIC, cd, "boot", bsmType)));
				cob.invokevirtual(ClassDesc.of("java.io.PrintStream"), "println", MethodTypeDesc.of(CD_void, CD_double));
				cob.return_();
			})
			.withMethodBody("boot", bsmType, ACC_STATIC, cob -> {
				cob.dconst_1();
				cob.dreturn();
			});
		});
	}
}