├── .gitattributes ├── .gitignore ├── .idea ├── .gitignore ├── artifacts │ ├── mc_image_agent.xml │ └── mc_image_agent_optimize.xml ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── copyright │ ├── MPL.xml │ └── profiles_settings.xml ├── customTargets.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── jarRepositories.xml ├── kotlinc.xml ├── libraries │ ├── Gradle__com_github_oshi_oshi_core_5_7_5.xml │ ├── Gradle__com_google_code_findbugs_jsr305_3_0_2.xml │ ├── Gradle__com_google_code_gson_gson_2_8_0.xml │ ├── Gradle__com_google_guava_guava_21_0.xml │ ├── Gradle__com_ibm_icu_icu4j_66_1.xml │ ├── Gradle__com_mojang_authlib_2_3_31.xml │ ├── Gradle__com_mojang_blocklist_1_0_5.xml │ ├── Gradle__com_mojang_brigadier_1_0_18.xml │ ├── Gradle__com_mojang_datafixerupper_4_0_26.xml │ ├── Gradle__com_mojang_javabridge_1_1_23.xml │ ├── Gradle__com_mojang_minecraft_client_1_17_1.xml │ ├── Gradle__com_mojang_patchy_2_1_6.xml │ ├── Gradle__com_mojang_text2speech_1_11_3.xml │ ├── Gradle__com_squareup_javapoet_1_13_0.xml │ ├── Gradle__com_sun_istack_istack_commons_runtime_4_1_1.xml │ ├── Gradle__com_sun_istack_istack_commons_tools_4_1_1.xml │ ├── Gradle__com_sun_xml_bind_external_relaxng_datatype_4_0_0.xml │ ├── Gradle__com_sun_xml_bind_external_rngom_4_0_0.xml │ ├── Gradle__com_sun_xml_dtd_parser_dtd_parser_1_5_0.xml │ ├── Gradle__commons_codec_commons_codec_1_10.xml │ ├── Gradle__commons_io_commons_io_2_5.xml │ ├── Gradle__io_netty_netty_all_4_1_25_Final.xml │ ├── Gradle__it_unimi_dsi_fastutil_8_2_1.xml │ ├── Gradle__jakarta_activation_jakarta_activation_api_2_1_0.xml │ ├── Gradle__jakarta_xml_bind_jakarta_xml_bind_api_4_0_0.xml │ ├── Gradle__net_fabricmc_tiny_mappings_parser_0_3_0_build_17.xml │ ├── Gradle__net_java_dev_jna_jna_5_8_0.xml │ ├── Gradle__net_java_dev_jna_jna_platform_5_8_0.xml │ ├── Gradle__net_java_jinput_jinput_2_0_5.xml │ ├── Gradle__net_java_jutils_jutils_1_0_0.xml │ ├── Gradle__net_sf_jopt_simple_jopt_simple_5_0_3.xml │ ├── Gradle__org_apache_commons_commons_compress_1_8_1.xml │ ├── Gradle__org_apache_commons_commons_lang3_3_5.xml │ ├── Gradle__org_apache_httpcomponents_httpclient_4_3_3.xml │ ├── Gradle__org_apache_httpcomponents_httpcore_4_3_2.xml │ ├── Gradle__org_apache_logging_log4j_log4j_api_2_14_1.xml │ ├── Gradle__org_apache_logging_log4j_log4j_core_2_14_1.xml │ ├── Gradle__org_apache_logging_log4j_log4j_slf4j18_impl_2_14_1.xml │ ├── Gradle__org_eclipse_angus_angus_activation_1_0_0.xml │ ├── Gradle__org_glassfish_jaxb_codemodel_4_0_0.xml │ ├── Gradle__org_glassfish_jaxb_jaxb_core_4_0_0.xml │ ├── Gradle__org_glassfish_jaxb_jaxb_runtime_4_0_0.xml │ ├── Gradle__org_glassfish_jaxb_jaxb_xjc_4_0_0.xml │ ├── Gradle__org_glassfish_jaxb_txw2_4_0_0.xml │ ├── Gradle__org_glassfish_jaxb_xsom_4_0_0.xml │ ├── Gradle__org_graalvm_compiler_compiler_22_2_0.xml │ ├── Gradle__org_graalvm_nativeimage_native_image_base_22_2_0.xml │ ├── Gradle__org_graalvm_nativeimage_objectfile_22_2_0.xml │ ├── Gradle__org_graalvm_nativeimage_pointsto_22_2_0.xml │ ├── Gradle__org_graalvm_nativeimage_svm_22_2_0.xml │ ├── Gradle__org_graalvm_sdk_graal_sdk_22_2_0.xml │ ├── Gradle__org_graalvm_truffle_truffle_api_22_2_0.xml │ ├── Gradle__org_jetbrains_annotations_23_0_0.xml │ ├── Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_7_10.xml │ ├── Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_7_10.xml │ ├── Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_7_10.xml │ ├── Gradle__org_lwjgl_lwjgl_3_2_2.xml │ ├── Gradle__org_lwjgl_lwjgl_glfw_3_2_2.xml │ ├── Gradle__org_lwjgl_lwjgl_jemalloc_3_2_2.xml │ ├── Gradle__org_lwjgl_lwjgl_openal_3_2_2.xml │ ├── Gradle__org_lwjgl_lwjgl_opengl_3_2_2.xml │ ├── Gradle__org_lwjgl_lwjgl_stb_3_2_2.xml │ ├── Gradle__org_lwjgl_lwjgl_tinyfd_3_2_2.xml │ ├── Gradle__org_ow2_asm_asm_9_3.xml │ ├── Gradle__org_ow2_asm_asm_analysis_9_3.xml │ ├── Gradle__org_ow2_asm_asm_commons_9_3.xml │ ├── Gradle__org_ow2_asm_asm_tree_9_3.xml │ ├── Gradle__org_quiltmc_hashed_1_17_1.xml │ ├── Gradle__org_slf4j_jcl_over_slf4j_1_8_0_beta4.xml │ └── Gradle__org_slf4j_slf4j_api_1_8_0_beta4.xml ├── misc.xml ├── modules.xml ├── modules │ ├── mc-image-agent │ │ ├── mc-image.mc-image-agent.iml │ │ ├── mc-image.mc-image-agent.main.iml │ │ ├── mc-image.mc-image-agent.optimize.iml │ │ └── mc-image.mc-image-agent.test.iml │ ├── mc-image-lib │ │ ├── mc-image.mc-image-lib.iml │ │ ├── mc-image.mc-image-lib.main.iml │ │ ├── mc-image.mc-image-lib.optimize.iml │ │ └── mc-image.mc-image-lib.test.iml │ └── mc-image-substgen │ │ ├── mc-image.mc-image-substgen.iml │ │ ├── mc-image.mc-image-substgen.main.iml │ │ └── mc-image.mc-image-substgen.test.iml ├── runConfigurations │ ├── native_image_build_debug.xml │ └── substgen.xml └── vcs.xml ├── LICENSE ├── README.md ├── build.gradle.kts ├── build.sh ├── compile_stb.sh ├── dyncall ├── dyncall.h ├── dyncall_args.h ├── dyncall_callback.h ├── dyncall_config.h ├── dyncall_macros.h ├── dyncall_signature.h ├── dyncall_types.h ├── dyncall_value.h └── dynload.h ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libs.txt ├── lwjgl_malloc.h ├── mc-image-agent ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── de │ │ │ └── kb1000 │ │ │ └── mcimage │ │ │ └── agent │ │ │ ├── BooleanVariable.java │ │ │ ├── ClassDefiner.java │ │ │ ├── Config.java │ │ │ ├── DebugHooks.java │ │ │ ├── Mappings.java │ │ │ ├── PreMain.java │ │ │ ├── UnsafeUtil.java │ │ │ └── transformers │ │ │ ├── AWTNoToolkitTransformer.java │ │ │ ├── ClassDumper.java │ │ │ ├── ClinitExtender.java │ │ │ ├── DedicatedServerGuiExitTransformer.java │ │ │ ├── HashMapComparableForTransformer.java │ │ │ ├── JEmallocAllocatorClinitTransformer.java │ │ │ ├── SVMClassInitAnalysisTransformer.java │ │ │ ├── SVMReflectionMethodTraceTransformer.java │ │ │ └── SubstitutionRemapperTransformer.java │ └── resources │ │ └── META-INF │ │ └── MANIFEST.MF │ └── optimize │ ├── java │ └── de │ │ └── kb1000 │ │ └── mcimage │ │ └── agent │ │ ├── Hooks.java │ │ ├── OptimizePreMain.java │ │ └── transformers │ │ ├── AnnotationSubstitutionProcessorFixTransformer.java │ │ ├── EarlyClassAnalysisLoggerTransformer.java │ │ ├── EnumSwitchCaseStableTransformer.java │ │ ├── FallbackFeatureTransformer.java │ │ ├── InputUtilTransformer.java │ │ ├── MethodHandleFeatureTransformer.java │ │ └── UnsafeAllocatorTransformer.java │ └── resources │ └── META-INF │ └── MANIFEST.MF ├── mc-image-lib ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── de │ │ │ └── kb1000 │ │ │ └── mcimage │ │ │ ├── target │ │ │ ├── awt │ │ │ │ ├── Target_com_sun_imageio_plugins_jpeg_DHTMarkerSegment.java │ │ │ │ ├── Target_java_awt_AWTEvent.java │ │ │ │ ├── Target_java_awt_ActionEvent.java │ │ │ │ ├── Target_java_awt_Component.java │ │ │ │ ├── Target_java_awt_GraphicsEnvironment.java │ │ │ │ ├── Target_java_awt_MenuComponent.java │ │ │ │ ├── Target_java_awt_Toolkit.java │ │ │ │ ├── Target_java_util_EventObject.java │ │ │ │ ├── Target_javax_imageio_ImageIO.java │ │ │ │ ├── Target_sun_awt_AppContext.java │ │ │ │ └── Target_sun_awt_image_ImagingLib.java │ │ │ ├── commons │ │ │ │ └── Target_org_apache_commons_lang3_ObjectUtils.java │ │ │ ├── logging │ │ │ │ ├── Target_org_apache_logging_log4j_LogManager.java │ │ │ │ ├── Target_org_apache_logging_log4j_core_appender_rolling_RollingRandomAccessFileManager.java │ │ │ │ ├── Target_org_apache_logging_log4j_core_config_ConfigurationSource.java │ │ │ │ ├── Target_org_apache_logging_log4j_core_jmx_Server.java │ │ │ │ ├── Target_org_apache_logging_log4j_core_lookup_JndiLookup.java │ │ │ │ ├── Target_org_apache_logging_log4j_core_net_JndiManager.java │ │ │ │ ├── Target_org_apache_logging_log4j_core_script_ScriptManager.java │ │ │ │ ├── Target_org_apache_logging_log4j_core_selector_ClassLoaderContextSelector.java │ │ │ │ ├── Target_org_apache_logging_log4j_spi_AbstractLogger.java │ │ │ │ └── Target_org_slf4j_LoggerFactory.java │ │ │ ├── lwjgl │ │ │ │ ├── LWJGLNativeMallocSetup.java │ │ │ │ ├── ObjectHandle.java │ │ │ │ ├── ObjectHandles.java │ │ │ │ ├── PointerGraphBuilderPluginFeature.java │ │ │ │ ├── Target_org_lwjgl_openal_AL.java │ │ │ │ ├── Target_org_lwjgl_opengl_GL.java │ │ │ │ ├── Target_org_lwjgl_stb_LibSTB.java │ │ │ │ ├── Target_org_lwjgl_stb_STBImage.java │ │ │ │ ├── Target_org_lwjgl_stb_STBImageResize.java │ │ │ │ ├── Target_org_lwjgl_stb_STBImageWrite.java │ │ │ │ ├── Target_org_lwjgl_stb_STBVorbis.java │ │ │ │ ├── Target_org_lwjgl_system_Callback.java │ │ │ │ ├── Target_org_lwjgl_system_CustomBuffer.java │ │ │ │ ├── Target_org_lwjgl_system_Library.java │ │ │ │ ├── Target_org_lwjgl_system_MemoryAccessJNI.java │ │ │ │ ├── Target_org_lwjgl_system_MemoryStack.java │ │ │ │ ├── Target_org_lwjgl_system_MemoryUtil.java │ │ │ │ ├── Target_org_lwjgl_system_Pointer.java │ │ │ │ ├── Target_org_lwjgl_system_Struct.java │ │ │ │ ├── Target_org_lwjgl_system_ThreadLocalUtil.java │ │ │ │ ├── Target_org_lwjgl_system_dyncall_DynCallback.java │ │ │ │ ├── Target_org_lwjgl_system_dyncall_DynLoad.java │ │ │ │ ├── Target_org_lwjgl_system_jni_JNINativeInterface.java │ │ │ │ └── Target_org_lwjgl_system_linux_DynamicLinkLoader.java │ │ │ ├── mc │ │ │ │ ├── MinecraftClassNameProvider.java │ │ │ │ ├── Target_Identifier.java │ │ │ │ ├── Target_MinecraftClient.java │ │ │ │ ├── Target_MinecraftServer.java │ │ │ │ ├── Target_NativeImage.java │ │ │ │ ├── Target_PlayerSkinTexture.java │ │ │ │ ├── Target_RealmsTextureManager.java │ │ │ │ ├── Target_RealmsUtil.java │ │ │ │ ├── Target_RenderSystem.java │ │ │ │ └── Target_ServerMetadata.java │ │ │ ├── netty │ │ │ │ └── Target_io_netty_bootstrap_AbstractBootstrap.java │ │ │ └── svm │ │ │ │ └── Target_com_oracle_svm_core_jdk_resources_NativeImageResourceFileSystem.java │ │ │ └── util │ │ │ ├── CException.java │ │ │ ├── CStringConversion.java │ │ │ ├── Environment.java │ │ │ ├── HostedConstants.java │ │ │ ├── MappingsParser.java │ │ │ ├── dyncall │ │ │ ├── DynCallSVM.java │ │ │ ├── DynCallbackSVM.java │ │ │ └── DynLoadSVM.java │ │ │ └── stb │ │ │ ├── LibSTBDirectives.java │ │ │ ├── STBImageResizeSVM.java │ │ │ ├── STBImageSVM.java │ │ │ ├── STBImageWriteSVM.java │ │ │ └── STBVorbisSVM.java │ └── resources │ │ └── META-INF │ │ └── native-image │ │ ├── reflect-config.json │ │ └── resource-config.json │ └── optimize │ └── java │ └── de │ └── kb1000 │ └── mcimage │ ├── target │ ├── commons │ │ └── Target_org_apache_commons_io_Java7Support.java │ ├── gson │ │ └── Target_com_google_gson_internal_UnsafeAllocator.java │ ├── guava │ │ └── GuavaFeature.java │ ├── httpclient │ │ └── Target_org_apache_http_impl_auth_GGSSchemeBase.java │ ├── jdk │ │ ├── AccessControllerFeature.java │ │ ├── JCEKSDisableFeature.java │ │ ├── Target_com_oracle_svm_core_jdk_TrustStoreManagerSupport.java │ │ ├── Target_com_sun_crypto_provider_JceKeyStore.java │ │ ├── Target_java_io_ObjectInputStream.java │ │ ├── Target_java_lang_invoke_DelegatingMethodHandle.java │ │ ├── Target_java_lang_invoke_MethodHandle.java │ │ ├── Target_java_lang_invoke_VarHandleByteArrayAsInts_ByteArrayViewVarHandle.java │ │ ├── Target_sun_reflect_generics_reflectiveObjects_TypeVariableImpl.java │ │ └── VarHandleByteArrayAccessFeature.java │ └── logging │ │ ├── LogFactoryInitializerFeature.java │ │ ├── Target_io_netty_util_internal_logging_InternalLoggerFactory.java │ │ └── Target_org_apache_commons_logging_LogFactory.java │ └── util │ ├── Constants.java │ ├── GLFWAlias.java │ └── ThrowableUtil.java ├── mc-image-substgen ├── build.gradle.kts └── src │ └── main │ ├── java │ └── de │ │ └── kb1000 │ │ └── mcimage │ │ └── substgen │ │ └── jaxb │ │ ├── Alias.java │ │ ├── Commands.java │ │ ├── Enums.java │ │ ├── Extension.java │ │ ├── Extensions.java │ │ ├── Feature.java │ │ ├── Glx.java │ │ ├── Group.java │ │ ├── Groups.java │ │ ├── InterfaceElement.java │ │ ├── ObjectFactory.java │ │ ├── Param.java │ │ ├── Proto.java │ │ ├── Registry.java │ │ ├── Types.java │ │ ├── Unused.java │ │ └── Vecequiv.java │ └── kotlin │ └── de │ └── kb1000 │ └── mcimage │ └── substgen │ ├── GenerateCallbackBackend.kt │ ├── GenerateGLInvokers.kt │ ├── GenerateJNIInvokerSubstitution.kt │ ├── GeneratePatchedSharedSecrets.kt │ ├── GeneratePatchedTreeMap.kt │ ├── Main.kt │ └── Util.kt ├── mc-image.iml ├── minecraft-client-gdb.gdb ├── run.sh ├── settings.gradle.kts ├── stb.c ├── stb.h └── stb ├── stb_dxt.h ├── stb_easy_font.h ├── stb_image.h ├── stb_image_resize.h ├── stb_image_write.h ├── stb_perlin.h ├── stb_rect_pack.h ├── stb_truetype.h └── stb_vorbis.c /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # Linux start script should use lf 5 | /gradlew text eol=lf 6 | 7 | # These are Windows script files and should use crlf 8 | *.bat text eol=crlf 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /natives 2 | /saves 3 | /logs 4 | /crash-reports 5 | /reports 6 | minecraft-client* 7 | minecraft-server* 8 | !minecraft-client-gdb.gdb 9 | /mc-image-lib/gen 10 | /out 11 | /sources 12 | gl.xml 13 | *.class 14 | *.jar 15 | *.so 16 | *.a 17 | *.o 18 | svmhelpers.py 19 | /screenshots 20 | servers.dat 21 | options.txt 22 | usercache.json 23 | /assets 24 | .idea/discord.xml 25 | .idea/deployment.xml 26 | .idea/uiDesigner.xml 27 | env.sh 28 | /libraries 29 | /graalvm 30 | /graal_dumps 31 | *.log 32 | perf.data 33 | mc-image-config.txt 34 | /world 35 | ops.json 36 | server.properties 37 | whitelist.json 38 | eula.txt 39 | banned-ips.json 40 | banned-players.json 41 | classpaths.sh 42 | 43 | # Ignore Gradle project-specific cache directory 44 | .gradle 45 | 46 | # Ignore Gradle build output directory 47 | build 48 | 49 | !gradle/wrapper/gradle-wrapper.jar 50 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /.idea/artifacts/mc_image_agent.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/mc_image_agent 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/artifacts/mc_image_agent_optimize.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/mc_image_agent_optimize 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/copyright/MPL.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/customTargets.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 26 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_github_oshi_oshi_core_5_7_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_google_code_gson_gson_2_8_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_google_guava_guava_21_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_ibm_icu_icu4j_66_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_mojang_authlib_2_3_31.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_mojang_blocklist_1_0_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_mojang_brigadier_1_0_18.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_mojang_datafixerupper_4_0_26.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_mojang_javabridge_1_1_23.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_mojang_minecraft_client_1_17_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_mojang_patchy_2_1_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_mojang_text2speech_1_11_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_squareup_javapoet_1_13_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_sun_istack_istack_commons_runtime_4_1_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_sun_istack_istack_commons_tools_4_1_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_sun_xml_bind_external_relaxng_datatype_4_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_sun_xml_bind_external_rngom_4_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_sun_xml_dtd_parser_dtd_parser_1_5_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__commons_codec_commons_codec_1_10.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__commons_io_commons_io_2_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__io_netty_netty_all_4_1_25_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__it_unimi_dsi_fastutil_8_2_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__jakarta_activation_jakarta_activation_api_2_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__jakarta_xml_bind_jakarta_xml_bind_api_4_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__net_fabricmc_tiny_mappings_parser_0_3_0_build_17.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__net_java_dev_jna_jna_5_8_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__net_java_dev_jna_jna_platform_5_8_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__net_java_jinput_jinput_2_0_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__net_java_jutils_jutils_1_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__net_sf_jopt_simple_jopt_simple_5_0_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_apache_commons_commons_compress_1_8_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_apache_commons_commons_lang3_3_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_apache_httpcomponents_httpclient_4_3_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_apache_httpcomponents_httpcore_4_3_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_apache_logging_log4j_log4j_api_2_14_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_apache_logging_log4j_log4j_core_2_14_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_apache_logging_log4j_log4j_slf4j18_impl_2_14_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_eclipse_angus_angus_activation_1_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_glassfish_jaxb_codemodel_4_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_glassfish_jaxb_jaxb_core_4_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_glassfish_jaxb_jaxb_runtime_4_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_glassfish_jaxb_jaxb_xjc_4_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_glassfish_jaxb_txw2_4_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_glassfish_jaxb_xsom_4_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_graalvm_compiler_compiler_22_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_graalvm_nativeimage_native_image_base_22_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_graalvm_nativeimage_objectfile_22_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_graalvm_nativeimage_pointsto_22_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_graalvm_nativeimage_svm_22_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_graalvm_sdk_graal_sdk_22_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_graalvm_truffle_truffle_api_22_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_jetbrains_annotations_23_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_7_10.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_7_10.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_7_10.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_lwjgl_lwjgl_3_2_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_lwjgl_lwjgl_glfw_3_2_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_lwjgl_lwjgl_jemalloc_3_2_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_lwjgl_lwjgl_openal_3_2_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_lwjgl_lwjgl_opengl_3_2_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_lwjgl_lwjgl_stb_3_2_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_lwjgl_lwjgl_tinyfd_3_2_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_ow2_asm_asm_9_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_ow2_asm_asm_analysis_9_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_ow2_asm_asm_commons_9_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_ow2_asm_asm_tree_9_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_quiltmc_hashed_1_17_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_slf4j_jcl_over_slf4j_1_8_0_beta4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_slf4j_slf4j_api_1_8_0_beta4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/modules/mc-image-agent/mc-image.mc-image-agent.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/modules/mc-image-agent/mc-image.mc-image-agent.main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/modules/mc-image-agent/mc-image.mc-image-agent.optimize.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/modules/mc-image-agent/mc-image.mc-image-agent.test.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/modules/mc-image-lib/mc-image.mc-image-lib.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/modules/mc-image-substgen/mc-image.mc-image-substgen.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/runConfigurations/native_image_build_debug.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | -------------------------------------------------------------------------------- /.idea/runConfigurations/substgen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mc-image 2 | 3 | Compile Minecraft to a native executable using [GraalVM native-image](https://www.graalvm.org/native-image/)! 4 | 5 | ## Build instructions 6 | 7 | 1. Build the Gradle project using `./gradlew assemble` 8 | 2. Run `./build.sh` 9 | 10 | After a few minutes, a `minecraft-client` executable will have been produced. 11 | You can run it using `run.sh`, which passes a few arguments Minecraft requires. 12 | 13 | If you pass `--server` to `build.sh`, you will instead get a `minecraft-server` binary containing the server, and which you run directly instead of using `run.sh`. 14 | 15 | ### Binary distribution 16 | 17 | Since executables as generated by build.sh are essentially full distributions of the Minecraft codebase, the Minecraft EULA does not permit distributing them without explicit permission by Mojang. 18 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | buildscript { 10 | repositories { 11 | mavenCentral() 12 | } 13 | 14 | dependencies { 15 | classpath("com.google.code.gson:gson:2.9.1") 16 | } 17 | } -------------------------------------------------------------------------------- /compile_stb.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | rm -f libstb.a 3 | clang -Istb -flto=full -c -o stb.o -O2 -DNDEBUG -march=native -mtune=native stb.c 4 | llvm-ar rcs libstb.a stb.o 5 | -------------------------------------------------------------------------------- /dyncall/dyncall_args.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Package: dyncall 4 | Library: dyncallback 5 | File: dyncallback/dyncall_args.h 6 | Description: Callback's Arguments VM - Interface 7 | License: 8 | 9 | Copyright (c) 2007-2015 Daniel Adler , 10 | Tassilo Philipp 11 | 12 | Permission to use, copy, modify, and distribute this software for any 13 | purpose with or without fee is hereby granted, provided that the above 14 | copyright notice and this permission notice appear in all copies. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 17 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 18 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 19 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 20 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 21 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 22 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 23 | 24 | */ 25 | 26 | 27 | #ifndef DYNCALL_ARGS_H 28 | #define DYNCALL_ARGS_H 29 | 30 | /* 31 | * dyncall args C API 32 | * 33 | * dyncall args provides serialized access to arguments of a function call. 34 | * related concepts: callback 35 | * 36 | */ 37 | 38 | #include "dyncall.h" 39 | 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | typedef struct DCArgs DCArgs; 46 | 47 | DC_API DCbool dcbArgBool (DCArgs*); 48 | DC_API DCchar dcbArgChar (DCArgs*); 49 | DC_API DCshort dcbArgShort (DCArgs*); 50 | DC_API DCint dcbArgInt (DCArgs*); 51 | DC_API DClong dcbArgLong (DCArgs*); 52 | DC_API DClonglong dcbArgLongLong (DCArgs*); 53 | DC_API DCuchar dcbArgUChar (DCArgs*); 54 | DC_API DCushort dcbArgUShort (DCArgs*); 55 | DC_API DCuint dcbArgUInt (DCArgs*); 56 | DC_API DCulong dcbArgULong (DCArgs*); 57 | DC_API DCulonglong dcbArgULongLong(DCArgs*); 58 | DC_API DCfloat dcbArgFloat (DCArgs*); 59 | DC_API DCdouble dcbArgDouble (DCArgs*); 60 | DC_API DCpointer dcbArgPointer (DCArgs*); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* DYNCALL_ARGS_H */ 67 | -------------------------------------------------------------------------------- /dyncall/dyncall_callback.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Package: dyncall 4 | Library: dyncallback 5 | File: dyncallback/dyncall_callback.h 6 | Description: Callback - Interface 7 | License: 8 | 9 | Copyright (c) 2007-2016 Daniel Adler , 10 | Tassilo Philipp 11 | 12 | Permission to use, copy, modify, and distribute this software for any 13 | purpose with or without fee is hereby granted, provided that the above 14 | copyright notice and this permission notice appear in all copies. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 17 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 18 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 19 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 20 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 21 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 22 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 23 | 24 | */ 25 | 26 | #ifndef DYNCALL_CALLBACK_H 27 | #define DYNCALL_CALLBACK_H 28 | 29 | #include "dyncall_args.h" 30 | #include "dyncall_signature.h" 31 | #include "dyncall_value.h" 32 | 33 | typedef struct DCCallback DCCallback; 34 | 35 | // return value is the type encoded as a signature char (character of the set [vBcCsSiIjJlLfd]). 36 | typedef char (DCCallbackHandler)(DCCallback* pcb, DCArgs* args, DCValue* result, void* userdata); 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | DCCallback* dcbNewCallback(const char* signature, DCCallbackHandler* funcptr, void* userdata); 43 | void dcbInitCallback(DCCallback* pcb, const char* signature, DCCallbackHandler* handler, void* userdata); 44 | void dcbFreeCallback(DCCallback* pcb); 45 | void* dcbGetUserData (DCCallback* pcb); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* DYNCALL_CALLBACK_H */ 52 | -------------------------------------------------------------------------------- /dyncall/dyncall_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Package: dyncall 4 | Library: dyncall 5 | File: dyncall/dyncall_config.h 6 | Description: Macro configuration file for non-standard C types 7 | License: 8 | 9 | Copyright (c) 2007-2015 Daniel Adler , 10 | Tassilo Philipp 11 | 12 | Permission to use, copy, modify, and distribute this software for any 13 | purpose with or without fee is hereby granted, provided that the above 14 | copyright notice and this permission notice appear in all copies. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 17 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 18 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 19 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 20 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 21 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 22 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 23 | 24 | */ 25 | 26 | 27 | 28 | /* 29 | 30 | dyncall type configuration 31 | 32 | REVISION 33 | 2007/12/11 initial 34 | 35 | */ 36 | 37 | #ifndef DYNCALL_CONFIG_H 38 | #define DYNCALL_CONFIG_H 39 | 40 | #include "dyncall_macros.h" 41 | 42 | #define DC_BOOL int 43 | #define DC_LONG_LONG long long 44 | #define DC_POINTER void* 45 | 46 | #endif /* DYNCALL_CONFIG_H */ 47 | 48 | -------------------------------------------------------------------------------- /dyncall/dyncall_signature.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Package: dyncall 4 | Library: dyncall 5 | File: dyncall/dyncall_signature.h 6 | Description: Type and calling-convention signature character defines 7 | License: 8 | 9 | Copyright (c) 2007-2015 Daniel Adler , 10 | Tassilo Philipp 11 | 12 | Permission to use, copy, modify, and distribute this software for any 13 | purpose with or without fee is hereby granted, provided that the above 14 | copyright notice and this permission notice appear in all copies. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 17 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 18 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 19 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 20 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 21 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 22 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 23 | 24 | */ 25 | 26 | 27 | 28 | /* 29 | 30 | dyncall signature characters 31 | 32 | REVISION 33 | 2007/12/11 initial 34 | 35 | */ 36 | 37 | 38 | #ifndef DYNCALL_SIGNATURE_H 39 | #define DYNCALL_SIGNATURE_H 40 | 41 | typedef char DCsigchar; 42 | 43 | #define DC_SIGCHAR_VOID 'v' 44 | #define DC_SIGCHAR_BOOL 'B' 45 | #define DC_SIGCHAR_CHAR 'c' 46 | #define DC_SIGCHAR_UCHAR 'C' 47 | #define DC_SIGCHAR_SHORT 's' 48 | #define DC_SIGCHAR_USHORT 'S' 49 | #define DC_SIGCHAR_INT 'i' 50 | #define DC_SIGCHAR_UINT 'I' 51 | #define DC_SIGCHAR_LONG 'j' 52 | #define DC_SIGCHAR_ULONG 'J' 53 | #define DC_SIGCHAR_LONGLONG 'l' 54 | #define DC_SIGCHAR_ULONGLONG 'L' 55 | #define DC_SIGCHAR_FLOAT 'f' 56 | #define DC_SIGCHAR_DOUBLE 'd' 57 | #define DC_SIGCHAR_POINTER 'p' 58 | #define DC_SIGCHAR_STRING 'Z' 59 | #define DC_SIGCHAR_STRUCT 'T' 60 | #define DC_SIGCHAR_ENDARG ')' /* also works for end struct */ 61 | 62 | /* callback signatures */ 63 | 64 | #define DC_SIGCHAR_CC_PREFIX '_' 65 | #define DC_SIGCHAR_CC_ELLIPSIS 'e' 66 | #define DC_SIGCHAR_CC_STDCALL 's' 67 | #define DC_SIGCHAR_CC_FASTCALL_GNU 'f' 68 | #define DC_SIGCHAR_CC_FASTCALL_MS 'F' 69 | #define DC_SIGCHAR_CC_THISCALL_MS '+' 70 | 71 | #endif /* DYNCALL_SIGNATURE_H */ 72 | 73 | -------------------------------------------------------------------------------- /dyncall/dyncall_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Package: dyncall 4 | Library: dyncall 5 | File: dyncall/dyncall_types.h 6 | Description: Typedefs 7 | License: 8 | 9 | Copyright (c) 2007-2015 Daniel Adler , 10 | Tassilo Philipp 11 | 12 | Permission to use, copy, modify, and distribute this software for any 13 | purpose with or without fee is hereby granted, provided that the above 14 | copyright notice and this permission notice appear in all copies. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 17 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 18 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 19 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 20 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 21 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 22 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 23 | 24 | */ 25 | 26 | 27 | 28 | /* 29 | 30 | dyncall argument- and return-types 31 | 32 | REVISION 33 | 2007/12/11 initial 34 | 35 | */ 36 | 37 | #ifndef DYNCALL_TYPES_H 38 | #define DYNCALL_TYPES_H 39 | 40 | #include 41 | 42 | #include "dyncall_config.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | typedef void DCvoid; 49 | typedef DC_BOOL DCbool; 50 | typedef char DCchar; 51 | typedef unsigned char DCuchar; 52 | typedef short DCshort; 53 | typedef unsigned short DCushort; 54 | typedef int DCint; 55 | typedef unsigned int DCuint; 56 | typedef long DClong; 57 | typedef unsigned long DCulong; 58 | typedef DC_LONG_LONG DClonglong; 59 | typedef unsigned DC_LONG_LONG DCulonglong; 60 | typedef float DCfloat; 61 | typedef double DCdouble; 62 | typedef DC_POINTER DCpointer; 63 | typedef const char* DCstring; 64 | typedef size_t DCsize; 65 | 66 | #define DC_TRUE 1 67 | #define DC_FALSE 0 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* DYNCALL_TYPES_H */ 74 | 75 | -------------------------------------------------------------------------------- /dyncall/dynload.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Package: dyncall 4 | Library: dynload 5 | File: dynload/dynload.h 6 | Description: public header for library dynload 7 | License: 8 | 9 | Copyright (c) 2007-2015 Daniel Adler , 10 | Tassilo Philipp 11 | 12 | Permission to use, copy, modify, and distribute this software for any 13 | purpose with or without fee is hereby granted, provided that the above 14 | copyright notice and this permission notice appear in all copies. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 17 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 18 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 19 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 20 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 21 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 22 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 23 | 24 | */ 25 | 26 | 27 | 28 | #ifndef DYNLOAD_H 29 | #define DYNLOAD_H 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | #ifndef DL_API 36 | #define DL_API 37 | #endif 38 | 39 | 40 | /* shared library loading and explicit symbol resolving */ 41 | /* dlLoadLibrary will search for specified lib (e.g. as leaf name, only), */ 42 | /* to the platforms dynamic linking style */ 43 | 44 | typedef struct DLLib_ DLLib; 45 | 46 | DL_API DLLib* dlLoadLibrary (const char* libPath); 47 | DL_API void dlFreeLibrary (DLLib* pLib); 48 | DL_API void* dlFindSymbol (DLLib* pLib, const char* pSymbolName); 49 | DL_API int dlGetLibraryPath(DLLib* pLib, char* sOut, int bufSize); 50 | 51 | 52 | /* symbol table enumeration - only for symbol lookup, not resolve */ 53 | /* note that dlSymsInit does not search library paths */ 54 | 55 | typedef struct DLSyms_ DLSyms; 56 | 57 | DL_API DLSyms* dlSymsInit (const char* libPath); 58 | DL_API void dlSymsCleanup(DLSyms* pSyms); 59 | 60 | DL_API int dlSymsCount (DLSyms* pSyms); 61 | DL_API const char* dlSymsName (DLSyms* pSyms, int index); 62 | DL_API const char* dlSymsNameFromValue(DLSyms* pSyms, void* value); /* symbol must be loaded */ 63 | 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* DYNLOAD_H */ 70 | 71 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021-2022 kb1000. 3 | # 4 | # This Source Code Form is subject to the terms of the Mozilla Public 5 | # License, v. 2.0. If a copy of the MPL was not distributed with this 6 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | # 8 | 9 | org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kb-1000/mc-image/7151531d01f57aaadeddeaeaa035de67de094160/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /libs.txt: -------------------------------------------------------------------------------- 1 | https://build.lwjgl.org/release/3.2.2/linux/x64/libdynload_s.a 2 | https://build.lwjgl.org/release/3.2.2/linux/x64/libdyncallback_s.a 3 | -------------------------------------------------------------------------------- /lwjgl_malloc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #define LWJGL_MALLOC(function) org_lwjgl_##function 7 | 8 | // Overridable memory management functions 9 | 10 | typedef void* (*mallocPROC) (size_t); 11 | typedef void* (*callocPROC) (size_t num, size_t size); 12 | typedef void* (*reallocPROC) (void *ptr, size_t size); 13 | typedef void (*freePROC) (void *ptr); 14 | typedef void* (*aligned_allocPROC) (size_t alignment, size_t size); 15 | typedef void (*aligned_freePROC) (void *ptr); 16 | 17 | extern mallocPROC org_lwjgl_malloc; 18 | extern callocPROC org_lwjgl_calloc; 19 | extern reallocPROC org_lwjgl_realloc; 20 | extern freePROC org_lwjgl_free; 21 | 22 | extern aligned_allocPROC org_lwjgl_aligned_alloc; 23 | extern aligned_freePROC org_lwjgl_aligned_free; 24 | 25 | -------------------------------------------------------------------------------- /mc-image-agent/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | plugins { 10 | java 11 | } 12 | 13 | repositories { 14 | mavenCentral() 15 | } 16 | 17 | dependencies { 18 | implementation(project(":mc-image-lib", configuration = "graal")) 19 | } 20 | 21 | sourceSets { 22 | create("optimize") { 23 | compileClasspath += sourceSets.main.get().output 24 | runtimeClasspath += sourceSets.main.get().output 25 | } 26 | } 27 | 28 | 29 | configurations { 30 | getByName("optimizeCompileClasspath") { 31 | extendsFrom(compileClasspath.get()) 32 | } 33 | 34 | getByName("optimizeRuntimeClasspath") { 35 | extendsFrom(runtimeClasspath.get()) 36 | } 37 | } 38 | 39 | tasks.withType { 40 | options.compilerArgs.addAll(listOf("--add-modules", "jdk.internal.vm.ci", "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", "--add-exports", "java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED", "--add-exports", "java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED", "--add-exports", "jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED", "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED", "--add-exports", "java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED")) 41 | } 42 | 43 | tasks.jar { 44 | manifest { 45 | from("src/main/resources/META-INF/MANIFEST.MF") 46 | } 47 | } 48 | 49 | val optimizeJar: Jar by tasks.creating(Jar::class) { 50 | manifest { 51 | from("src/optimize/resources/META-INF/MANIFEST.MF") 52 | } 53 | archiveClassifier.set("optimize") 54 | from(sourceSets.main.get().output, sourceSets["optimize"].output) 55 | } 56 | tasks.assemble { 57 | dependsOn(optimizeJar) 58 | } -------------------------------------------------------------------------------- /mc-image-agent/src/main/java/de/kb1000/mcimage/agent/BooleanVariable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent; 10 | 11 | public class BooleanVariable { 12 | public boolean value; 13 | } 14 | -------------------------------------------------------------------------------- /mc-image-agent/src/main/java/de/kb1000/mcimage/agent/ClassDefiner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent; 10 | 11 | public class ClassDefiner { 12 | /*public static Class defineClass(ClassLoader classLoader, byte[] bytes) { 13 | return UnsafeUtil.UNSAFE.defineClass(null, bytes, 0, bytes.length, classLoader, null); 14 | }*/ 15 | } 16 | -------------------------------------------------------------------------------- /mc-image-agent/src/main/java/de/kb1000/mcimage/agent/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent; 10 | 11 | import java.io.*; 12 | import java.nio.charset.StandardCharsets; 13 | import java.util.ArrayList; 14 | import java.util.HashSet; 15 | import java.util.Set; 16 | 17 | public class Config { 18 | public static final Set traceReflectionMethods; 19 | 20 | static { 21 | ArrayList traceReflectionMethodsList = new ArrayList<>(); 22 | try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream("mc-image-config.txt"), StandardCharsets.UTF_8))) { 23 | String line; 24 | while ((line = bufferedReader.readLine()) != null) { 25 | line = line.trim(); 26 | if (line.isEmpty()) { 27 | continue; 28 | } 29 | if (line.startsWith("traceReflectionMethod:")) { 30 | traceReflectionMethodsList.add(line.substring("traceReflectionMethod:".length())); 31 | } 32 | } 33 | } catch (FileNotFoundException ignored) { 34 | } catch (IOException e) { 35 | throw new RuntimeException(e); 36 | } 37 | 38 | traceReflectionMethods = new HashSet<>(traceReflectionMethodsList); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /mc-image-agent/src/main/java/de/kb1000/mcimage/agent/DebugHooks.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent; 10 | 11 | public class DebugHooks { 12 | public static void hook() {} 13 | } 14 | -------------------------------------------------------------------------------- /mc-image-agent/src/main/java/de/kb1000/mcimage/agent/Mappings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent; 10 | 11 | import java.util.Map; 12 | 13 | @SuppressWarnings("unchecked") 14 | public class Mappings { 15 | public static final Map CLASS_MAPPED_UNMAPPED; 16 | public static final Map METHOD_MAPPED_UNMAPPED; 17 | public static final Map FIELD_MAPPED_UNMAPPED; 18 | 19 | static { 20 | try { 21 | Class mappingParser = ClassLoader.getSystemClassLoader().loadClass("de.kb1000.mcimage.util.MappingsParser"); 22 | CLASS_MAPPED_UNMAPPED = (Map) mappingParser.getField("CLASS_MAPPED_UNMAPPED").get(null); 23 | METHOD_MAPPED_UNMAPPED = (Map) mappingParser.getField("METHOD_MAPPED_UNMAPPED").get(null); 24 | FIELD_MAPPED_UNMAPPED = (Map) mappingParser.getField("FIELD_MAPPED_UNMAPPED").get(null); 25 | Util.isLoaded = true; 26 | } catch (Throwable e) { 27 | e.printStackTrace(); 28 | throw new Error(e); 29 | } 30 | } 31 | 32 | public static class Util { 33 | public static boolean isLoaded = false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /mc-image-agent/src/main/java/de/kb1000/mcimage/agent/UnsafeUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent; 10 | 11 | import java.lang.invoke.MethodHandles; 12 | import java.lang.reflect.Field; 13 | 14 | public class UnsafeUtil { 15 | public static final MethodHandles.Lookup IMPL_LOOKUP; 16 | 17 | static { 18 | try { 19 | Field field = MethodHandles.Lookup.class.getDeclaredField("IMPL_LOOKUP"); 20 | field.setAccessible(true); 21 | IMPL_LOOKUP = (MethodHandles.Lookup) field.get(null); 22 | } catch (IllegalAccessException | NoSuchFieldException e) { 23 | throw new RuntimeException(e); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /mc-image-agent/src/main/java/de/kb1000/mcimage/agent/transformers/ClassDumper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent.transformers; 10 | 11 | import java.io.IOException; 12 | import java.io.OutputStream; 13 | import java.lang.instrument.ClassFileTransformer; 14 | import java.lang.instrument.IllegalClassFormatException; 15 | import java.nio.file.Files; 16 | import java.nio.file.Path; 17 | import java.security.ProtectionDomain; 18 | 19 | public class ClassDumper implements ClassFileTransformer { 20 | @Override 21 | public byte[] transform(Module module, ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { 22 | var file = Path.of("classes", className + ".class"); 23 | try { 24 | Files.createDirectories(file.getParent()); 25 | try (final OutputStream os = Files.newOutputStream(file)) { 26 | os.write(classfileBuffer); 27 | } 28 | } catch (IOException e) { 29 | throw new RuntimeException(e); 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /mc-image-agent/src/main/java/de/kb1000/mcimage/agent/transformers/ClinitExtender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent.transformers; 10 | 11 | import jdk.internal.org.objectweb.asm.ClassVisitor; 12 | import jdk.internal.org.objectweb.asm.MethodVisitor; 13 | import jdk.internal.org.objectweb.asm.Opcodes; 14 | 15 | public abstract class ClinitExtender extends ClassVisitor { 16 | private final boolean atEnd; 17 | private boolean visitedClinit = false; 18 | 19 | public ClinitExtender(ClassVisitor classVisitor, boolean atEnd) { 20 | super(Opcodes.ASM8, classVisitor); 21 | this.atEnd = atEnd; 22 | } 23 | 24 | protected abstract void emitClinitCode(MethodVisitor mv); 25 | 26 | @Override 27 | public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { 28 | MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions); 29 | if (name.equals("")) { 30 | visitedClinit = true; 31 | return new MethodVisitor(Opcodes.ASM8, mv) { 32 | @Override 33 | public void visitCode() { 34 | super.visitCode(); 35 | if (!atEnd) { 36 | emitClinitCode(this); 37 | } 38 | } 39 | 40 | @Override 41 | public void visitInsn(int opcode) { 42 | if (atEnd && opcode == Opcodes.RETURN) { 43 | emitClinitCode(this); 44 | } 45 | super.visitInsn(opcode); 46 | } 47 | }; 48 | } 49 | return mv; 50 | } 51 | 52 | @Override 53 | public void visitEnd() { 54 | if (!visitedClinit) { 55 | MethodVisitor mv = visitMethod(Opcodes.ACC_STATIC, "", "()V", null, null); 56 | mv.visitCode(); 57 | mv.visitInsn(Opcodes.RETURN); 58 | mv.visitMaxs(-1, -1); 59 | mv.visitEnd(); 60 | } 61 | super.visitEnd(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /mc-image-agent/src/main/java/de/kb1000/mcimage/agent/transformers/HashMapComparableForTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent.transformers; 10 | 11 | import jdk.internal.org.objectweb.asm.ClassReader; 12 | import jdk.internal.org.objectweb.asm.ClassVisitor; 13 | import jdk.internal.org.objectweb.asm.ClassWriter; 14 | import jdk.internal.org.objectweb.asm.MethodVisitor; 15 | 16 | import java.lang.instrument.ClassFileTransformer; 17 | import java.lang.instrument.IllegalClassFormatException; 18 | import java.security.ProtectionDomain; 19 | 20 | import static jdk.internal.org.objectweb.asm.Opcodes.ASM8; 21 | 22 | // workaround for https://github.com/oracle/graal/issues/4982 23 | public class HashMapComparableForTransformer implements ClassFileTransformer { 24 | @Override 25 | public byte[] transform(Module module, ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { 26 | switch (className) { 27 | case "com/oracle/svm/core/jdk/Target_java_util_HashMap": 28 | case "com/oracle/svm/core/jdk/Target_java_util_concurrent_ConcurrentHashMap": 29 | ClassReader classReader = new ClassReader(classfileBuffer); 30 | ClassWriter classWriter = new ClassWriter(classReader, 0); 31 | classReader.accept(new ClassVisitor(ASM8, classWriter) { 32 | @Override 33 | public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { 34 | return name.equals("comparableClassFor") ? null : super.visitMethod(access, name, descriptor, signature, exceptions); 35 | } 36 | }, 0); 37 | return classWriter.toByteArray(); 38 | default: 39 | return null; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /mc-image-agent/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Agent-Class: de.kb1000.mcimage.agent.PreMain 3 | Premain-Class: de.kb1000.mcimage.agent.PreMain 4 | 5 | -------------------------------------------------------------------------------- /mc-image-agent/src/optimize/java/de/kb1000/mcimage/agent/Hooks.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent; 10 | 11 | import com.oracle.svm.core.SubstrateOptions; 12 | import com.oracle.svm.core.annotate.RecomputeFieldValue; 13 | import com.oracle.svm.hosted.substitute.AnnotatedField; 14 | import com.oracle.svm.hosted.substitute.ComputedValueField; 15 | import jdk.vm.ci.meta.ResolvedJavaField; 16 | 17 | public class Hooks { 18 | public static boolean equalsAnnotationSubstitutionProcessorOriginalField(ResolvedJavaField existingAlias, ResolvedJavaField original, ResolvedJavaField computedAlias) { 19 | // standard case 20 | if (existingAlias.equals(original)) return true; 21 | if (existingAlias instanceof ComputedValueField existingComputedValueField && existingComputedValueField.getRecomputeValueKind() == RecomputeFieldValue.Kind.None && computedAlias instanceof ComputedValueField computedValueField) { 22 | // TODO: should check caching and other flags, but this should do for now 23 | return true; 24 | } 25 | // this should be safe to allow replacing (@InjectAccessors replacing an @Alias field without re-computation) 26 | return existingAlias instanceof ComputedValueField computedValueField && computedValueField.getRecomputeValueKind() == RecomputeFieldValue.Kind.None && computedAlias instanceof AnnotatedField; 27 | } 28 | 29 | public static boolean transformFallbackInConfig(boolean inConfig) { 30 | return inConfig && !Integer.valueOf(0).equals(SubstrateOptions.FallbackThreshold.getValue()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mc-image-agent/src/optimize/java/de/kb1000/mcimage/agent/OptimizePreMain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent; 10 | 11 | import de.kb1000.mcimage.agent.transformers.*; 12 | 13 | import java.lang.instrument.Instrumentation; 14 | 15 | public class OptimizePreMain { 16 | public static void premain(final String arg, final Instrumentation instrumentation) throws Throwable { 17 | PreMain.premain(arg, instrumentation); 18 | instrumentation.addTransformer(new AnnotationSubstitutionProcessorFixTransformer()); // only used in mc-image-lib.optimize 19 | instrumentation.addTransformer(new InputUtilTransformer()); 20 | instrumentation.addTransformer(new MethodHandleFeatureTransformer()); 21 | instrumentation.addTransformer(new FallbackFeatureTransformer()); 22 | instrumentation.addTransformer(new EarlyClassAnalysisLoggerTransformer()); 23 | instrumentation.addTransformer(new EnumSwitchCaseStableTransformer()); 24 | instrumentation.addTransformer(new UnsafeAllocatorTransformer()); 25 | //instrumentation.addTransformer(new ClassDumper()); 26 | } 27 | 28 | public static void agentmain(final String arg, final Instrumentation instrumentation) throws Throwable { 29 | premain(arg, instrumentation); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mc-image-agent/src/optimize/java/de/kb1000/mcimage/agent/transformers/EnumSwitchCaseStableTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.agent.transformers; 10 | 11 | import de.kb1000.mcimage.agent.BooleanVariable; 12 | import jdk.internal.org.objectweb.asm.ClassReader; 13 | import jdk.internal.org.objectweb.asm.ClassVisitor; 14 | import jdk.internal.org.objectweb.asm.ClassWriter; 15 | import jdk.internal.org.objectweb.asm.FieldVisitor; 16 | 17 | import java.lang.instrument.ClassFileTransformer; 18 | import java.lang.instrument.IllegalClassFormatException; 19 | import java.security.ProtectionDomain; 20 | 21 | import static jdk.internal.org.objectweb.asm.Opcodes.ASM8; 22 | 23 | public class EnumSwitchCaseStableTransformer implements ClassFileTransformer { 24 | @Override 25 | public byte[] transform(Module module, ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { 26 | char c = className.charAt(className.length() - 1); 27 | if (c <= '9' && c >= '0' && className.contains("$")) { 28 | var isChanged = new BooleanVariable(); 29 | ClassReader classReader = new ClassReader(classfileBuffer); 30 | ClassWriter classWriter = new ClassWriter(classReader, 0); 31 | classReader.accept(new ClassVisitor(ASM8, classWriter) { 32 | @Override 33 | public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) { 34 | FieldVisitor fv = super.visitField(access, name, descriptor, signature, value); 35 | if (fv != null && name.startsWith("$SwitchMap$") && descriptor.equals("[I")) { 36 | isChanged.value = true; 37 | fv.visitAnnotation("Ljdk/internal/vm/annotation/Stable;", true); 38 | } 39 | return fv; 40 | } 41 | }, 0); 42 | if (isChanged.value) 43 | return classWriter.toByteArray(); 44 | } 45 | return null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /mc-image-agent/src/optimize/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Agent-Class: de.kb1000.mcimage.agent.OptimizePreMain 3 | Premain-Class: de.kb1000.mcimage.agent.OptimizePreMain 4 | 5 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/awt/Target_com_sun_imageio_plugins_jpeg_DHTMarkerSegment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.awt; 10 | 11 | import com.oracle.svm.core.annotate.Delete; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | 14 | @TargetClass(className = "com.sun.imageio.plugins.jpeg.DHTMarkerSegment") 15 | @Delete 16 | final class Target_com_sun_imageio_plugins_jpeg_DHTMarkerSegment { 17 | } 18 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/awt/Target_java_awt_AWTEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.awt; 10 | 11 | import com.oracle.svm.core.SubstrateUtil; 12 | import com.oracle.svm.core.annotate.Delete; 13 | import com.oracle.svm.core.annotate.Substitute; 14 | import com.oracle.svm.core.annotate.TargetClass; 15 | 16 | import java.awt.*; 17 | 18 | @TargetClass(className = "java.awt.peer.ComponentPeer") 19 | @Delete 20 | final class Target_java_awt_peer_ComponentPeer { 21 | } 22 | 23 | @TargetClass(className = "java.security.AccessControlContext") 24 | final class Target_java_security_AccessControlContext { 25 | } 26 | 27 | @TargetClass(AWTEvent.class) 28 | final class Target_java_awt_AWTEvent { 29 | @Delete 30 | byte[] bdata; 31 | 32 | @Delete 33 | int id; 34 | 35 | @Delete 36 | boolean consumed; 37 | 38 | @Delete 39 | Target_java_security_AccessControlContext acc; 40 | 41 | @Delete 42 | boolean focusManagerIsDispatching; 43 | 44 | @Delete 45 | boolean isPosted; 46 | 47 | @Delete 48 | boolean isSystemGenerated; 49 | 50 | @Delete 51 | native void setSource(Object newSource); 52 | 53 | @Delete 54 | native void nativeSetSource(Target_java_awt_peer_ComponentPeer peer); 55 | 56 | @Substitute 57 | Target_java_awt_AWTEvent(Object source, int id) { 58 | SubstrateUtil.cast(this, Target_java_util_EventObject.class).source = source; 59 | } 60 | 61 | @Substitute 62 | public String toString() { 63 | return super.toString(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/awt/Target_java_awt_ActionEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.awt; 10 | 11 | import com.oracle.svm.core.annotate.Delete; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | 14 | import java.awt.event.ActionEvent; 15 | 16 | // TODO: MC uses this, for whatever reason 17 | @TargetClass(ActionEvent.class) 18 | //@Substitute 19 | final class Target_java_awt_ActionEvent { 20 | @Delete 21 | native String getActionCommand(); 22 | 23 | @Delete 24 | native long getWhen(); 25 | 26 | @Delete 27 | native int getModifiers(); 28 | 29 | @Delete 30 | native String paramString(); 31 | } 32 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/awt/Target_java_awt_Component.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.awt; 10 | 11 | import com.oracle.svm.core.annotate.Delete; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | 14 | import java.awt.*; 15 | 16 | @TargetClass(Component.class) 17 | @Delete 18 | final class Target_java_awt_Component { 19 | } 20 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/awt/Target_java_awt_MenuComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.awt; 10 | 11 | import com.oracle.svm.core.annotate.Delete; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | 14 | import java.awt.*; 15 | 16 | @TargetClass(MenuComponent.class) 17 | @Delete 18 | final class Target_java_awt_MenuComponent { 19 | } 20 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/awt/Target_java_awt_Toolkit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.awt; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | 14 | @TargetClass(className = "java.awt.Toolkit") 15 | @Substitute // @Delete would break the reachability handler, and @Substitute still deletes all members 16 | final class Target_java_awt_Toolkit { 17 | // Can't remove everything but can kill the library loading 18 | // (unfortunately, that's not going to keep it from linking AWT in, this is prevented in the agent) 19 | @Substitute 20 | static void loadLibraries() {} 21 | 22 | @Substitute 23 | static void initStatic() {} 24 | } 25 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/awt/Target_java_util_EventObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.awt; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | 14 | import java.util.EventObject; 15 | 16 | @TargetClass(EventObject.class) 17 | final class Target_java_util_EventObject { 18 | @Alias 19 | Object source; 20 | } 21 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/awt/Target_javax_imageio_ImageIO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.awt; 10 | 11 | import com.oracle.svm.core.annotate.Delete; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | 14 | import javax.imageio.ImageIO; 15 | 16 | @TargetClass(ImageIO.class) 17 | @Delete 18 | final class Target_javax_imageio_ImageIO { 19 | } 20 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/awt/Target_sun_awt_AppContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.awt; 10 | 11 | import com.oracle.svm.core.annotate.Delete; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | 14 | @TargetClass(className = "sun.awt.AppContext") 15 | @Delete 16 | final class Target_sun_awt_AppContext { 17 | } 18 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/awt/Target_sun_awt_image_ImagingLib.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.awt; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | 14 | @TargetClass(className = "sun.awt.image.ImagingLib") 15 | @Substitute // @Delete would break the reachability handler, and @Substitute still deletes all members 16 | final class Target_sun_awt_image_ImagingLib { 17 | } 18 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/logging/Target_org_apache_logging_log4j_core_appender_rolling_RollingRandomAccessFileManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.logging; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.RecomputeFieldValue; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | import org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager; 15 | 16 | import java.io.RandomAccessFile; 17 | 18 | @TargetClass(RollingRandomAccessFileManager.class) 19 | final class Target_org_apache_logging_log4j_core_appender_rolling_RollingRandomAccessFileManager { 20 | @Alias 21 | @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) 22 | private RandomAccessFile randomAccessFile; 23 | } 24 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/logging/Target_org_apache_logging_log4j_core_config_ConfigurationSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.logging; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.RecomputeFieldValue; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | import org.apache.logging.log4j.core.config.ConfigurationSource; 15 | 16 | import java.io.InputStream; 17 | 18 | @TargetClass(ConfigurationSource.class) 19 | final class Target_org_apache_logging_log4j_core_config_ConfigurationSource { 20 | @Alias 21 | @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) 22 | private InputStream stream; 23 | } 24 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/logging/Target_org_apache_logging_log4j_core_jmx_Server.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.logging; 10 | 11 | import com.oracle.svm.core.annotate.Delete; 12 | import com.oracle.svm.core.annotate.Substitute; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | import org.apache.logging.log4j.core.jmx.Server; 15 | 16 | import javax.management.MBeanServer; 17 | 18 | // Disable JMX support of log4j 19 | @TargetClass(Server.class) 20 | final class Target_org_apache_logging_log4j_core_jmx_Server { 21 | @Substitute 22 | private static boolean isJmxDisabled() { 23 | return true; 24 | } 25 | 26 | @Substitute 27 | static void reregisterMBeansAfterReconfigure() { 28 | } 29 | 30 | @Delete 31 | static native void reregisterMBeansAfterReconfigure(final MBeanServer mbs); 32 | 33 | @Substitute 34 | static void unregisterMBeans() { 35 | } 36 | 37 | @Delete 38 | static native void unregisterMBeans(final MBeanServer mbs); 39 | 40 | @Substitute 41 | static void unregisterLoggerContext(final String loggerContextName) { 42 | } 43 | 44 | @Delete 45 | static native void unregisterLoggerContext(final String contextName, final MBeanServer mbs); 46 | } 47 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/logging/Target_org_apache_logging_log4j_core_lookup_JndiLookup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.logging; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import org.apache.logging.log4j.core.LogEvent; 14 | import org.apache.logging.log4j.core.lookup.JndiLookup; 15 | 16 | @TargetClass(JndiLookup.class) 17 | final class Target_org_apache_logging_log4j_core_lookup_JndiLookup { 18 | @Substitute 19 | public String lookup(LogEvent event, String key) { 20 | return null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/logging/Target_org_apache_logging_log4j_core_net_JndiManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.logging; 10 | 11 | import com.oracle.svm.core.annotate.Delete; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import org.apache.logging.log4j.core.net.JndiManager; 14 | 15 | @TargetClass(JndiManager.class) 16 | @Delete 17 | final class Target_org_apache_logging_log4j_core_net_JndiManager { 18 | } 19 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/logging/Target_org_apache_logging_log4j_core_script_ScriptManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.logging; 10 | 11 | import com.oracle.svm.core.annotate.AlwaysInline; 12 | import com.oracle.svm.core.annotate.Substitute; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | import org.apache.logging.log4j.core.config.Configuration; 15 | import org.apache.logging.log4j.core.script.AbstractScript; 16 | import org.apache.logging.log4j.core.script.ScriptManager; 17 | import org.apache.logging.log4j.core.util.WatchManager; 18 | 19 | @Substitute 20 | @TargetClass(ScriptManager.class) 21 | final class Target_org_apache_logging_log4j_core_script_ScriptManager { 22 | @Substitute 23 | @AlwaysInline("") 24 | public Target_org_apache_logging_log4j_core_script_ScriptManager(final Configuration configuration, final WatchManager watchManager) { 25 | throw new RuntimeException(); 26 | } 27 | 28 | @Substitute 29 | @AlwaysInline("") 30 | public void addScript(final AbstractScript script) { 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/logging/Target_org_apache_logging_log4j_spi_AbstractLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.logging; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import org.apache.logging.log4j.message.DefaultFlowMessageFactory; 14 | import org.apache.logging.log4j.message.FlowMessageFactory; 15 | import org.apache.logging.log4j.message.MessageFactory2; 16 | import org.apache.logging.log4j.message.ParameterizedMessageFactory; 17 | import org.apache.logging.log4j.spi.AbstractLogger; 18 | 19 | @TargetClass(AbstractLogger.class) 20 | final class Target_org_apache_logging_log4j_spi_AbstractLogger { 21 | @Substitute 22 | private static MessageFactory2 createDefaultMessageFactory() { 23 | return new ParameterizedMessageFactory(); 24 | } 25 | 26 | @Substitute 27 | private static FlowMessageFactory createDefaultFlowMessageFactory() { 28 | return new DefaultFlowMessageFactory(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/logging/Target_org_slf4j_LoggerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.logging; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import org.slf4j.LoggerFactory; 14 | import org.slf4j.spi.SLF4JServiceProvider; 15 | 16 | import java.net.URL; 17 | import java.util.List; 18 | import java.util.Set; 19 | 20 | // Disable StaticLoggerBinder 21 | @TargetClass(LoggerFactory.class) 22 | final class Target_org_slf4j_LoggerFactory { 23 | @Substitute 24 | private static List findServiceProviders() { 25 | return List.of(new org.apache.logging.slf4j.SLF4JServiceProvider()); 26 | } 27 | 28 | @Substitute 29 | static Set findPossibleStaticLoggerBinderPathSet() { 30 | return Set.of(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/LWJGLNativeMallocSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.c.CGlobalData; 12 | import com.oracle.svm.core.c.CGlobalDataFactory; 13 | import org.graalvm.nativeimage.c.CContext; 14 | import org.graalvm.nativeimage.c.type.CCharPointerPointer; 15 | 16 | @CContext(LWJGLNativeMallocSetup.Directives.class) 17 | public final class LWJGLNativeMallocSetup { 18 | public static class Directives implements CContext.Directives { 19 | } 20 | 21 | // not actually char pointers, but should still generate correct code 22 | // TODO: clean up the types 23 | static final CGlobalData org_lwjgl_malloc = CGlobalDataFactory.forSymbol("org_lwjgl_malloc"); 24 | static final CGlobalData org_lwjgl_calloc = CGlobalDataFactory.forSymbol("org_lwjgl_calloc"); 25 | static final CGlobalData org_lwjgl_realloc = CGlobalDataFactory.forSymbol("org_lwjgl_realloc"); 26 | static final CGlobalData org_lwjgl_free = CGlobalDataFactory.forSymbol("org_lwjgl_free"); 27 | 28 | static final CGlobalData org_lwjgl_aligned_alloc = CGlobalDataFactory.forSymbol("org_lwjgl_aligned_alloc"); 29 | static final CGlobalData org_lwjgl_aligned_free = CGlobalDataFactory.forSymbol("org_lwjgl_aligned_free"); 30 | } 31 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/ObjectHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import org.graalvm.word.ComparableWord; 12 | 13 | public interface ObjectHandle extends ComparableWord { 14 | } 15 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_openal_AL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.Substitute; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | import de.kb1000.mcimage.util.Environment; 15 | import org.lwjgl.openal.ALCapabilities; 16 | 17 | import javax.annotation.Nullable; 18 | 19 | @TargetClass(className = "org.lwjgl.openal.AL", onlyWith = Environment.ClientOnly.class) 20 | final class Target_org_lwjgl_openal_AL { 21 | @TargetClass(className = "org.lwjgl.openal.AL", innerClass = "ICDStatic", onlyWith = Environment.ClientOnly.class) 22 | static final class ICDStatic { 23 | @Alias 24 | @Nullable 25 | static ALCapabilities tempCaps; 26 | 27 | @Substitute 28 | void set(@Nullable ALCapabilities caps) { 29 | if (tempCaps == null) { 30 | tempCaps = caps; 31 | } else if (tempCaps != caps && caps != null) { 32 | throw new IllegalStateException("Capabilities already set!"); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_stb_LibSTB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import de.kb1000.mcimage.util.Environment; 14 | import org.graalvm.word.WordFactory; 15 | 16 | @TargetClass(className = "org.lwjgl.stb.LibSTB", onlyWith = Environment.ClientOnly.class) 17 | final class Target_org_lwjgl_stb_LibSTB { 18 | @Substitute 19 | static void setupMalloc(long malloc, long calloc, long realloc, long free, long aligned_alloc, long aligned_free) { 20 | LWJGLNativeMallocSetup.org_lwjgl_malloc.get().write(WordFactory.pointer(malloc)); 21 | LWJGLNativeMallocSetup.org_lwjgl_calloc.get().write(WordFactory.pointer(calloc)); 22 | LWJGLNativeMallocSetup.org_lwjgl_realloc.get().write(WordFactory.pointer(realloc)); 23 | LWJGLNativeMallocSetup.org_lwjgl_free.get().write(WordFactory.pointer(free)); 24 | 25 | LWJGLNativeMallocSetup.org_lwjgl_aligned_alloc.get().write(WordFactory.pointer(aligned_alloc)); 26 | LWJGLNativeMallocSetup.org_lwjgl_aligned_free.get().write(WordFactory.pointer(aligned_free)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_stb_STBImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import de.kb1000.mcimage.util.CException; 14 | import de.kb1000.mcimage.util.Environment; 15 | import de.kb1000.mcimage.util.stb.STBImageSVM; 16 | import org.graalvm.word.WordFactory; 17 | 18 | @TargetClass(className = "org.lwjgl.stb.STBImage", onlyWith = Environment.ClientOnly.class) 19 | final class Target_org_lwjgl_stb_STBImage { 20 | @Substitute 21 | static long nstbi_load_from_memory(long buffer, int len, long x, long y, long channels_in_file, int desired_channels) { 22 | return STBImageSVM.stbi_load_from_memory(WordFactory.pointer(buffer), len, WordFactory.pointer(x), WordFactory.pointer(y), WordFactory.pointer(channels_in_file), desired_channels).rawValue(); 23 | } 24 | 25 | @Substitute 26 | static long nstbi_failure_reason() { 27 | return STBImageSVM.stbi_failure_reason().rawValue(); 28 | } 29 | 30 | @Substitute 31 | static void nstbi_image_free(long retval_from_stbi_load) { 32 | STBImageSVM.stbi_image_free(WordFactory.pointer(retval_from_stbi_load)); 33 | } 34 | 35 | @Substitute 36 | static int nstbi_info_from_callbacks(long clbk, long user, long x, long y, long comp) throws Throwable { 37 | var result = STBImageSVM.stbi_info_from_callbacks(WordFactory.pointer(clbk), WordFactory.pointer(user), WordFactory.pointer(x), WordFactory.pointer(y), WordFactory.pointer(comp)); 38 | CException.rethrow(); 39 | return result; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_stb_STBImageResize.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import de.kb1000.mcimage.util.Environment; 14 | import de.kb1000.mcimage.util.stb.STBImageResizeSVM; 15 | import org.graalvm.word.WordFactory; 16 | 17 | @TargetClass(className = "org.lwjgl.stb.STBImageResize", onlyWith = Environment.ClientOnly.class) 18 | final class Target_org_lwjgl_stb_STBImageResize { 19 | @Substitute 20 | static int nstbir_resize_uint8(long input_pixels, int input_w, int input_h, int input_stride_in_bytes, long output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels) { 21 | return STBImageResizeSVM.stbir_resize_uint8(WordFactory.pointer(input_pixels), input_w, input_h, input_stride_in_bytes, WordFactory.pointer(output_pixels), output_w, output_h, output_stride_in_bytes, num_channels); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_stb_STBImageWrite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import de.kb1000.mcimage.util.CException; 14 | import de.kb1000.mcimage.util.Environment; 15 | import de.kb1000.mcimage.util.stb.STBImageWriteSVM; 16 | import org.graalvm.word.WordFactory; 17 | 18 | @TargetClass(className = "org.lwjgl.stb.STBImageWrite", onlyWith = Environment.ClientOnly.class) 19 | final class Target_org_lwjgl_stb_STBImageWrite { 20 | @Substitute 21 | static long nstbi_write_png_compression_level() { 22 | return STBImageWriteSVM.stbi_write_png_compression_level.get().rawValue(); 23 | } 24 | 25 | @Substitute 26 | static long nstbi_write_force_png_filter() { 27 | return STBImageWriteSVM.stbi_write_force_png_filter.get().rawValue(); 28 | } 29 | 30 | @Substitute 31 | static long nstbi_zlib_compress() { 32 | return STBImageWriteSVM.stbi_zlib_compress.get().rawValue(); 33 | } 34 | 35 | @Substitute 36 | static long nstbi_write_tga_with_rle() { 37 | return STBImageWriteSVM.stbi_write_tga_with_rle.get().rawValue(); 38 | } 39 | 40 | @Substitute 41 | static int nstbi_write_png_to_func(long func, long context, int w, int h, int comp, long data, int stride_in_bytes) throws Throwable { 42 | var result = STBImageWriteSVM.stbi_write_png_to_func(WordFactory.pointer(func), WordFactory.pointer(context), w, h, comp, WordFactory.pointer(data), stride_in_bytes); 43 | CException.rethrow(); 44 | return result; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_stb_STBVorbis.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import de.kb1000.mcimage.util.Environment; 14 | import de.kb1000.mcimage.util.stb.STBVorbisSVM; 15 | import org.graalvm.word.WordFactory; 16 | 17 | @TargetClass(className = "org.lwjgl.stb.STBVorbis", onlyWith = Environment.ClientOnly.class) 18 | final class Target_org_lwjgl_stb_STBVorbis { 19 | @Substitute 20 | static void nstb_vorbis_get_info(long f, long __result) { 21 | STBVorbisSVM.nstb_vorbis_get_info(WordFactory.pointer(f), WordFactory.pointer(__result)); 22 | } 23 | 24 | @Substitute 25 | static int nstb_vorbis_get_error(long f) { 26 | return STBVorbisSVM.stb_vorbis_get_error(WordFactory.pointer(f)); 27 | } 28 | 29 | @Substitute 30 | static void nstb_vorbis_close(long f) { 31 | STBVorbisSVM.stb_vorbis_close(WordFactory.pointer(f)); 32 | } 33 | 34 | @Substitute 35 | static long nstb_vorbis_open_pushdata(long datablock, int datablock_length_in_bytes, long datablock_memory_consumed_in_bytes, long error, long alloc_buffer) { 36 | return STBVorbisSVM.stb_vorbis_open_pushdata(WordFactory.pointer(datablock), datablock_length_in_bytes, WordFactory.pointer(datablock_memory_consumed_in_bytes), WordFactory.pointer(error), WordFactory.pointer(alloc_buffer)).rawValue(); 37 | } 38 | 39 | @Substitute 40 | static int nstb_vorbis_decode_frame_pushdata(long f, long datablock, int datablock_length_in_bytes, long channels, long output, long samples) { 41 | return STBVorbisSVM.stb_vorbis_decode_frame_pushdata(WordFactory.pointer(f), WordFactory.pointer(datablock), datablock_length_in_bytes, WordFactory.pointer(channels), WordFactory.pointer(output), WordFactory.pointer(samples)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_system_Callback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import de.kb1000.mcimage.target.lwjgl.generated.Callbacks; 14 | import de.kb1000.mcimage.util.CStringConversion; 15 | import de.kb1000.mcimage.util.Environment; 16 | import de.kb1000.mcimage.util.dyncall.DynCallbackSVM.DCCallback; 17 | import de.kb1000.mcimage.util.dyncall.DynCallbackSVM.DCCallbackHandler; 18 | import org.graalvm.word.PointerBase; 19 | 20 | import static de.kb1000.mcimage.util.dyncall.DynCallbackSVM.dcbNewCallback; 21 | 22 | @TargetClass(className = "org.lwjgl.system.Callback", onlyWith = Environment.ClientOnly.class) 23 | final class Target_org_lwjgl_system_Callback { 24 | @Substitute 25 | static long create(String signature, Object instance) { 26 | DCCallbackHandler funcptr = Callbacks.getNativeFunction(signature.charAt(signature.length() - 1)); 27 | 28 | DCCallback handle; 29 | try (var cSignature = CStringConversion.toLatin1String(signature)) { 30 | handle = dcbNewCallback(cSignature.get(), funcptr, (PointerBase) ObjectHandles.create(instance)); 31 | } 32 | if (handle.isNull()) { 33 | throw new IllegalStateException("Failed to create the DCCallback object"); 34 | } 35 | 36 | return handle.rawValue(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_system_CustomBuffer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.Delete; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | import de.kb1000.mcimage.util.Environment; 15 | 16 | import javax.annotation.Nullable; 17 | import java.nio.ByteBuffer; 18 | 19 | // TODO: there are Unsafe calls here 20 | @TargetClass(className = "org.lwjgl.system.CustomBuffer", onlyWith = Environment.ClientOnly.class) 21 | final class Target_org_lwjgl_system_CustomBuffer { 22 | @Alias 23 | @Nullable 24 | ByteBuffer container; 25 | 26 | @Alias 27 | int mark, position, limit, capacity; 28 | 29 | // the Unsafe calls are in here, but the methods are not used, so we can @Delete them (to ensure they won't be, either) 30 | @Delete 31 | native Target_org_lwjgl_system_CustomBuffer slice(); 32 | @Delete 33 | native Target_org_lwjgl_system_CustomBuffer slice(int offset, int capacity); 34 | @Delete 35 | native Target_org_lwjgl_system_CustomBuffer duplicate(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_system_Library.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import de.kb1000.mcimage.util.Environment; 14 | 15 | import java.util.function.Consumer; 16 | 17 | @TargetClass(className = "org.lwjgl.system.Library", onlyWith = Environment.ClientOnly.class) 18 | final class Target_org_lwjgl_system_Library { 19 | // loadSystem *should* only be used for loading JNI libs, and JNI libs are unwanted here. 20 | // Disable this code. 21 | @Substitute 22 | static void loadSystem(String name) { 23 | } 24 | 25 | @Substitute 26 | static void loadSystem(Consumer load, Consumer loadLibrary, Class context, String name) { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_system_MemoryStack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.Delete; 13 | import com.oracle.svm.core.annotate.Substitute; 14 | import com.oracle.svm.core.annotate.TargetClass; 15 | import de.kb1000.mcimage.util.Environment; 16 | 17 | import javax.annotation.Nullable; 18 | import java.nio.ByteBuffer; 19 | 20 | import static org.lwjgl.system.MemoryUtil.memAddress; 21 | 22 | @SuppressWarnings("InstantiationOfUtilityClass") 23 | @TargetClass(className = "org.lwjgl.system.MemoryStack", onlyWith = Environment.ClientOnly.class) 24 | final class Target_org_lwjgl_system_MemoryStack { 25 | @Alias 26 | Target_org_lwjgl_system_MemoryStack(@Nullable ByteBuffer container, long address, int size) { 27 | } 28 | 29 | @Substitute 30 | public static Target_org_lwjgl_system_MemoryStack create(ByteBuffer buffer) { 31 | long address = memAddress(buffer); 32 | int size = buffer.remaining(); 33 | return new Target_org_lwjgl_system_MemoryStack(buffer, address, size); 34 | } 35 | 36 | @Substitute 37 | static Target_org_lwjgl_system_MemoryStack ncreate(long address, int size) { 38 | return new Target_org_lwjgl_system_MemoryStack(null, address, size); 39 | } 40 | 41 | @TargetClass(className = "org.lwjgl.system.MemoryStack$DebugMemoryStack", onlyWith = Environment.ClientOnly.class) 42 | @Delete 43 | static final class Target_DebugMemoryStack { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_system_ThreadLocalUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import de.kb1000.mcimage.util.Environment; 14 | import org.lwjgl.PointerBuffer; 15 | 16 | import javax.annotation.Nullable; 17 | 18 | @TargetClass(className = "org.lwjgl.system.ThreadLocalUtil", onlyWith = Environment.ClientOnly.class) 19 | @Substitute 20 | final class Target_org_lwjgl_system_ThreadLocalUtil { 21 | @Substitute 22 | static PointerBuffer getAddressesFromCapabilities(Object caps) { 23 | // never used, just kill 24 | return null; 25 | } 26 | 27 | @Substitute 28 | static void setFunctionMissingAddresses(@Nullable Class capabilitiesClass, int index) { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_system_dyncall_DynLoad.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import de.kb1000.mcimage.util.Environment; 14 | import de.kb1000.mcimage.util.dyncall.DynLoadSVM; 15 | import org.graalvm.word.WordFactory; 16 | 17 | @TargetClass(className = "org.lwjgl.system.dyncall.DynLoad", onlyWith = Environment.ClientOnly.class) 18 | final class Target_org_lwjgl_system_dyncall_DynLoad { 19 | @Substitute 20 | static long ndlLoadLibrary(long libpath) { 21 | return DynLoadSVM.dlLoadLibrary(WordFactory.pointer(libpath)).rawValue(); 22 | } 23 | 24 | @Substitute 25 | static void ndlFreeLibrary(long pLib) { 26 | DynLoadSVM.dlFreeLibrary(WordFactory.pointer(pLib)); 27 | } 28 | 29 | @Substitute 30 | static long ndlFindSymbol(long pLib, long pSymbolName) { 31 | return DynLoadSVM.dlFindSymbol(WordFactory.pointer(pLib), WordFactory.pointer(pSymbolName)).rawValue(); 32 | } 33 | 34 | @Substitute 35 | static int ndlGetLibraryPath(long pLib, long sOut, int bufSize) { 36 | return DynLoadSVM.dlGetLibraryPath(WordFactory.pointer(pLib), WordFactory.pointer(sOut), bufSize); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_system_jni_JNINativeInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.KeepOriginal; 12 | import com.oracle.svm.core.annotate.Substitute; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | import de.kb1000.mcimage.util.Environment; 15 | import org.graalvm.word.WordFactory; 16 | 17 | @TargetClass(className = "org.lwjgl.system.jni.JNINativeInterface", onlyWith = Environment.ClientOnly.class) 18 | @Substitute // Kill the JNI interface, it's not needed here... 19 | final class Target_org_lwjgl_system_jni_JNINativeInterface { 20 | // ... except for global references, which are used by Callback. Emulate that here. 21 | @Substitute 22 | static long NewGlobalRef(Object obj) { 23 | return ObjectHandles.create(obj).rawValue(); 24 | } 25 | 26 | @Substitute 27 | static void nDeleteGlobalRef(long globalRef) { 28 | ObjectHandles.destroy(WordFactory.signed(globalRef)); 29 | } 30 | 31 | @KeepOriginal 32 | static native void DeleteGlobalRef(long globalRef); 33 | } 34 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/lwjgl/Target_org_lwjgl_system_linux_DynamicLinkLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.lwjgl; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import com.oracle.svm.core.posix.headers.Dlfcn; 14 | import de.kb1000.mcimage.util.Environment; 15 | import org.graalvm.nativeimage.Platform; 16 | import org.graalvm.nativeimage.Platforms; 17 | import org.graalvm.word.WordFactory; 18 | 19 | @TargetClass(className = "org.lwjgl.system.linux.DynamicLinkLoader", onlyWith = Environment.ClientOnly.class) 20 | @Platforms(Platform.LINUX.class) 21 | final class Target_org_lwjgl_system_linux_DynamicLinkLoader { 22 | @Substitute 23 | static long ndlopen(long filename, int mode) { 24 | return Dlfcn.dlopen(WordFactory.pointer(filename), mode).rawValue(); 25 | } 26 | 27 | @Substitute 28 | static long ndlerror() { 29 | return Dlfcn.dlerror().rawValue(); 30 | } 31 | 32 | @Substitute 33 | static long ndlsym(long handle, long name) { 34 | return Dlfcn.dlsym(WordFactory.pointer(handle), WordFactory.pointer(name)).rawValue(); 35 | } 36 | 37 | @Substitute 38 | static int ndlclose(long handle) { 39 | return Dlfcn.dlclose(WordFactory.pointer(handle)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/mc/MinecraftClassNameProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.mc; 10 | 11 | import com.oracle.svm.core.annotate.TargetClass; 12 | import de.kb1000.mcimage.util.MappingsParser; 13 | import org.graalvm.nativeimage.Platform; 14 | import org.graalvm.nativeimage.Platforms; 15 | 16 | import java.util.function.Function; 17 | 18 | @Platforms(Platform.HOSTED_ONLY.class) 19 | public class MinecraftClassNameProvider implements Function { 20 | @Override 21 | public String apply(TargetClass targetClass) { 22 | return MappingsParser.CLASS_MAPPED_UNMAPPED.getOrDefault(targetClass.className(), targetClass.className()).replace('/', '.'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/mc/Target_Identifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.mc; 10 | 11 | import com.oracle.svm.core.annotate.TargetClass; 12 | 13 | @TargetClass(className = "net/minecraft/unmapped/C_ncpywfca", classNameProvider = MinecraftClassNameProvider.class) 14 | final class Target_Identifier { 15 | } 16 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/mc/Target_MinecraftClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.mc; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import com.oracle.svm.core.annotate.TargetElement; 14 | import de.kb1000.mcimage.util.Environment; 15 | 16 | import java.net.Proxy; 17 | 18 | @TargetClass(className = "net/minecraft/unmapped/C_ayfeobid", classNameProvider = MinecraftClassNameProvider.class, onlyWith = Environment.ClientOnly.class) 19 | final class Target_MinecraftClient { 20 | @Alias 21 | @TargetElement(name = "m_wipirsgk") 22 | static native Target_MinecraftClient getInstance(); 23 | @Alias 24 | @TargetElement(name = "m_lwpmozmo") 25 | native Proxy getNetworkProxy(); 26 | } 27 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/mc/Target_MinecraftServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.mc; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.Substitute; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | import com.oracle.svm.core.annotate.TargetElement; 15 | import net.minecraft.server.MinecraftServer; 16 | import org.apache.logging.log4j.Logger; 17 | 18 | import java.io.File; 19 | import java.nio.charset.StandardCharsets; 20 | import java.nio.file.Files; 21 | import java.util.Base64; 22 | 23 | @TargetClass(MinecraftServer.class) 24 | final class Target_MinecraftServer { 25 | @Alias 26 | @TargetElement(name = "f_tcqyqsco") 27 | static Logger LOGGER; 28 | 29 | @Substitute 30 | @TargetElement(name = "m_sednkjtc") 31 | static void loadServerIcon_lambda1(Target_ServerMetadata metadata, File file) { 32 | // see, it's not my problem if you provide an invalid image 33 | // just don't do that, and you'll be fine 34 | try { 35 | byte[] icon = Base64.getEncoder().encode(Files.readAllBytes(file.toPath())); 36 | metadata.setServerIcon("data:image/png;base64," + new String(icon, StandardCharsets.UTF_8)); 37 | } catch (Exception e) { 38 | LOGGER.error("Couldn't load server icon", e); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/mc/Target_NativeImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.mc; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import com.oracle.svm.core.annotate.TargetElement; 14 | import de.kb1000.mcimage.util.Environment; 15 | 16 | import java.io.IOException; 17 | import java.io.InputStream; 18 | import java.nio.ByteBuffer; 19 | 20 | @TargetClass(className = "net/minecraft/unmapped/C_ayikuhxa", classNameProvider = MinecraftClassNameProvider.class, onlyWith = Environment.ClientOnly.class) 21 | final class Target_NativeImage { 22 | @Alias 23 | Target_NativeImage(int width, int height, boolean useStb) { 24 | } 25 | 26 | @Alias 27 | @TargetElement(name = "m_mtdfbkkq") 28 | static native Target_NativeImage read(InputStream stream) throws IOException; 29 | 30 | @Alias 31 | @TargetElement(name = "m_meplyfkd") 32 | static native Target_NativeImage read(ByteBuffer stream) throws IOException; 33 | 34 | @Alias 35 | @TargetElement(name = "m_xqjgvqoz") 36 | native int getHeight(); 37 | 38 | @Alias 39 | @TargetElement(name = "m_glzwbqla") 40 | native byte[] getBytes(); 41 | 42 | @Alias 43 | @TargetElement(name = "m_urfoahpt") 44 | native void copyFrom(Target_NativeImage image); 45 | 46 | @Alias 47 | native void close(); 48 | 49 | @Alias 50 | @TargetElement(name = "m_csziyqyg") 51 | native void fillRect(int x, int y, int width, int height, int color); 52 | 53 | @Alias 54 | @TargetElement(name = "m_pdrvxmhc") 55 | native void copyRect(int x, int y, int translateX, int translateY, int width, int height, boolean flipX, boolean flipY); 56 | 57 | @Alias 58 | @TargetElement(name = "m_tqikshlo") 59 | native void upload(int level, int offsetX, int offsetY, boolean close); 60 | } 61 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/mc/Target_PlayerSkinTexture.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.mc; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import com.oracle.svm.core.annotate.TargetElement; 14 | import de.kb1000.mcimage.util.Environment; 15 | 16 | @TargetClass(className = "net/minecraft/unmapped/C_mcqxlzsy", classNameProvider = MinecraftClassNameProvider.class, onlyWith = Environment.ClientOnly.class) 17 | final class Target_PlayerSkinTexture { 18 | @Alias 19 | @TargetElement(name = "m_tgesoskb") 20 | static native void stripColor(Target_NativeImage image, int x1, int y1, int x2, int y2); 21 | 22 | @Alias 23 | @TargetElement(name = "m_xoaxgzjn") 24 | static native void stripAlpha(Target_NativeImage image, int x1, int y1, int x2, int y2); 25 | } 26 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/mc/Target_RealmsUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.mc; 10 | 11 | import com.mojang.authlib.minecraft.MinecraftProfileTexture; 12 | import com.oracle.svm.core.annotate.Alias; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | import com.oracle.svm.core.annotate.TargetElement; 15 | import de.kb1000.mcimage.util.Environment; 16 | 17 | import java.util.Map; 18 | 19 | @TargetClass(className = "net/minecraft/unmapped/C_veycqpnp", classNameProvider = MinecraftClassNameProvider.class, onlyWith = Environment.ClientOnly.class) 20 | final class Target_RealmsUtil { 21 | @Alias 22 | @TargetElement(name = "m_gbelqhtj") 23 | static native Map getTextures(String uuid); 24 | } 25 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/mc/Target_RenderSystem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.mc; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import de.kb1000.mcimage.util.Environment; 14 | 15 | @TargetClass(className = "com.mojang.blaze3d.systems.RenderSystem", onlyWith = Environment.ClientOnly.class) 16 | final class Target_RenderSystem { 17 | @Alias 18 | static native void setShaderTexture(int var0, Target_Identifier var1); 19 | } 20 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/mc/Target_ServerMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.mc; 10 | 11 | import com.oracle.svm.core.annotate.Alias; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import com.oracle.svm.core.annotate.TargetElement; 14 | 15 | @TargetClass(className = "net/minecraft/unmapped/C_bwttende", classNameProvider = MinecraftClassNameProvider.class) 16 | final class Target_ServerMetadata { 17 | @Alias 18 | @TargetElement(name = "m_tjisblji") 19 | native void setServerIcon(String serverIcon); 20 | } 21 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/target/svm/Target_com_oracle_svm_core_jdk_resources_NativeImageResourceFileSystem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.svm; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import com.oracle.svm.core.jdk.resources.NativeImageResourceFileSystem; 14 | 15 | import java.util.Map; 16 | 17 | @TargetClass(NativeImageResourceFileSystem.class) 18 | final class Target_com_oracle_svm_core_jdk_resources_NativeImageResourceFileSystem { 19 | // ZipFileSystem doesn't seem to have this check, thus Minecraft doesn't set create=true 20 | // Because modifying MC code directly would require version-specific code, kill the check instead 21 | @Substitute 22 | static boolean isTrue(Map env) { 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/util/CException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util; 10 | 11 | import com.oracle.svm.core.threadlocal.FastThreadLocalFactory; 12 | import com.oracle.svm.core.threadlocal.FastThreadLocalObject; 13 | 14 | public class CException { 15 | public static final FastThreadLocalObject pendingException = FastThreadLocalFactory.createObject(Throwable.class, "CException.pendingException"); 16 | 17 | public static void rethrow() throws Throwable { 18 | Throwable t; 19 | if ((t = pendingException.get()) != null) { 20 | pendingException.set(null); 21 | throw t; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/util/CStringConversion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util; 10 | 11 | import org.graalvm.nativeimage.PinnedObject; 12 | import org.graalvm.nativeimage.c.type.CCharPointer; 13 | import org.graalvm.nativeimage.c.type.CTypeConversion; 14 | 15 | public class CStringConversion { 16 | public static CTypeConversion.CCharPointerHolder toLatin1String(String s) { 17 | return new CCharPointerHolderImpl(s); 18 | } 19 | 20 | private static final class CCharPointerHolderImpl implements CTypeConversion.CCharPointerHolder { 21 | private final PinnedObject cString; 22 | 23 | CCharPointerHolderImpl(String javaString) { 24 | int len = javaString.length(); 25 | byte[] bytes = new byte[len + 1]; 26 | // Using the "broken" getBytes method is intended here, it seems to behave just like LWJGL's encodeASCII 27 | javaString.getBytes(0, len, bytes, 0); 28 | cString = PinnedObject.create(bytes); 29 | } 30 | 31 | @Override 32 | public CCharPointer get() { 33 | return cString.addressOfArrayElement(0); 34 | } 35 | 36 | @Override 37 | public void close() { 38 | cString.close(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/util/Environment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util; 10 | 11 | import java.util.function.BooleanSupplier; 12 | 13 | public class Environment { 14 | public static final boolean SERVER = Boolean.getBoolean("de.kb1000.mcimage.server"); 15 | 16 | public static final class ServerOnly implements BooleanSupplier { 17 | @Override 18 | public boolean getAsBoolean() { 19 | return SERVER; 20 | } 21 | } 22 | public static final class ClientOnly implements BooleanSupplier { 23 | @Override 24 | public boolean getAsBoolean() { 25 | return !SERVER; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/util/HostedConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util; 10 | 11 | import jdk.internal.misc.Unsafe; 12 | import org.graalvm.nativeimage.Platform; 13 | import org.graalvm.nativeimage.Platforms; 14 | 15 | import java.lang.invoke.MethodHandles; 16 | import java.lang.reflect.Field; 17 | 18 | public class HostedConstants { 19 | @Platforms(Platform.HOSTED_ONLY.class) 20 | public static final MethodHandles.Lookup IMPL_LOOKUP; 21 | public static final Unsafe UNSAFE = Unsafe.getUnsafe(); 22 | 23 | static { 24 | try { 25 | final Field implLookupField = MethodHandles.Lookup.class.getDeclaredField("IMPL_LOOKUP"); 26 | implLookupField.setAccessible(true); 27 | IMPL_LOOKUP = (MethodHandles.Lookup) implLookupField.get(null); 28 | } catch (NoSuchFieldException | IllegalAccessException e) { 29 | throw new RuntimeException(e); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/util/MappingsParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util; 10 | 11 | import net.fabricmc.mapping.tree.TinyMappingFactory; 12 | import net.fabricmc.mapping.tree.TinyTree; 13 | 14 | import java.io.BufferedReader; 15 | import java.io.InputStreamReader; 16 | import java.util.Map; 17 | import java.util.function.BinaryOperator; 18 | import java.util.stream.Collectors; 19 | 20 | public class MappingsParser { 21 | public static final Map CLASS_MAPPED_UNMAPPED; 22 | public static final Map METHOD_MAPPED_UNMAPPED; 23 | public static final Map FIELD_MAPPED_UNMAPPED; 24 | static { 25 | final String obfNamespace = "hashed"; 26 | final String runtimeNamespace = "official"; 27 | try (final BufferedReader br = new BufferedReader(new InputStreamReader(MappingsParser.class.getResourceAsStream("/mappings/mappings.tiny")))){ 28 | TinyTree tree = TinyMappingFactory.loadWithDetection(br, true); 29 | BinaryOperator duplicateHandler = (a, b) -> { 30 | if (!a.equals(b)) { 31 | throw new RuntimeException("Error: duplicate key with different values"); 32 | } 33 | return a; 34 | }; 35 | CLASS_MAPPED_UNMAPPED = tree.getClasses().stream().collect(Collectors.toUnmodifiableMap(c -> c.getName(obfNamespace), c -> c.getName(runtimeNamespace), duplicateHandler)); 36 | METHOD_MAPPED_UNMAPPED = tree.getClasses().stream().flatMap(c -> c.getMethods().stream()).collect(Collectors.toUnmodifiableMap(m -> m.getName(obfNamespace), m -> m.getName(runtimeNamespace), duplicateHandler)); 37 | FIELD_MAPPED_UNMAPPED = tree.getClasses().stream().flatMap(c -> c.getFields().stream()).collect(Collectors.toUnmodifiableMap(f -> f.getName(obfNamespace), f -> f.getName(runtimeNamespace), duplicateHandler)); 38 | } catch (Throwable e) { 39 | e.printStackTrace(); 40 | throw new Error(e); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/util/dyncall/DynLoadSVM.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util.dyncall; 10 | 11 | import org.graalvm.nativeimage.c.CContext; 12 | import org.graalvm.nativeimage.c.function.CFunction; 13 | import org.graalvm.nativeimage.c.struct.CStruct; 14 | import org.graalvm.nativeimage.c.type.CCharPointer; 15 | import org.graalvm.nativeimage.c.type.VoidPointer; 16 | import org.graalvm.word.PointerBase; 17 | 18 | @CContext(DynCallSVM.Directives.class) 19 | public final class DynLoadSVM { 20 | @CStruct(isIncomplete = true) 21 | public interface DLLib extends PointerBase { 22 | } 23 | 24 | @CStruct(isIncomplete = true) 25 | public interface DLSyms extends PointerBase { 26 | } 27 | 28 | @CFunction 29 | public static native DLLib dlLoadLibrary(CCharPointer libPath); 30 | 31 | @CFunction 32 | public static native void dlFreeLibrary(DLLib pLib); 33 | 34 | @CFunction 35 | public static native VoidPointer dlFindSymbol(DLLib pLib, CCharPointer pSymbolName); 36 | 37 | @CFunction 38 | public static native int dlGetLibraryPath(DLLib pLib, CCharPointer sOut, int bufSize); 39 | } 40 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/util/stb/LibSTBDirectives.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util.stb; 10 | 11 | import org.graalvm.nativeimage.c.CContext; 12 | 13 | import java.nio.file.Paths; 14 | import java.util.Collections; 15 | import java.util.List; 16 | 17 | public class LibSTBDirectives implements CContext.Directives { 18 | @Override 19 | public List getHeaderFiles() { 20 | return Collections.singletonList("\"" + Paths.get("stb.h").toAbsolutePath() + "\""); 21 | } 22 | 23 | @Override 24 | public List getLibraries() { 25 | return List.of("stb", "m"); 26 | } 27 | 28 | @Override 29 | public List getLibraryPaths() { 30 | return Collections.singletonList(Paths.get("").toAbsolutePath().toString()); 31 | } 32 | 33 | @Override 34 | public List getOptions() { 35 | return List.of("-I" + Paths.get("").toAbsolutePath(), "-I" + Paths.get("stb").toAbsolutePath()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/util/stb/STBImageResizeSVM.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util.stb; 10 | 11 | import org.graalvm.nativeimage.c.CContext; 12 | import org.graalvm.nativeimage.c.function.CFunction; 13 | import org.graalvm.nativeimage.c.type.CCharPointer; 14 | 15 | @CContext(LibSTBDirectives.class) 16 | public class STBImageResizeSVM { 17 | @CFunction 18 | public static native int stbir_resize_uint8(CCharPointer input_pixels, int input_w, int input_h, int input_stride_in_bytes, CCharPointer output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels); 19 | } 20 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/util/stb/STBImageSVM.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util.stb; 10 | 11 | import org.graalvm.nativeimage.c.CContext; 12 | import org.graalvm.nativeimage.c.function.CFunction; 13 | import org.graalvm.nativeimage.c.type.CCharPointer; 14 | import org.graalvm.nativeimage.c.type.CIntPointer; 15 | import org.graalvm.nativeimage.c.type.VoidPointer; 16 | import org.graalvm.word.PointerBase; 17 | 18 | @CContext(LibSTBDirectives.class) 19 | public class STBImageSVM { 20 | @CFunction 21 | public static native CCharPointer stbi_load_from_memory(CCharPointer buffer, int len, CIntPointer x, CIntPointer y, CIntPointer channels_in_file, int desired_channels); 22 | 23 | @CFunction 24 | public static native CCharPointer stbi_failure_reason(); 25 | 26 | @CFunction 27 | public static native void stbi_image_free(VoidPointer retval_from_stbi_load); 28 | 29 | @CFunction 30 | public static native int stbi_info_from_callbacks(/*STBIIOCallbacks*/ PointerBase clbk, VoidPointer user, CIntPointer x, CIntPointer y, CIntPointer comp); 31 | } 32 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/util/stb/STBImageWriteSVM.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util.stb; 10 | 11 | import com.oracle.svm.core.c.CGlobalData; 12 | import com.oracle.svm.core.c.CGlobalDataFactory; 13 | import org.graalvm.nativeimage.c.CContext; 14 | import org.graalvm.nativeimage.c.function.CFunction; 15 | import org.graalvm.nativeimage.c.type.CCharPointer; 16 | import org.graalvm.nativeimage.c.type.CCharPointerPointer; 17 | import org.graalvm.nativeimage.c.type.CIntPointer; 18 | import org.graalvm.nativeimage.c.type.VoidPointer; 19 | import org.graalvm.word.PointerBase; 20 | 21 | @CContext(LibSTBDirectives.class) 22 | public class STBImageWriteSVM { 23 | public static final CGlobalData stbi_write_png_compression_level = CGlobalDataFactory.forSymbol("stbi_write_png_compression_level"); 24 | public static final CGlobalData stbi_write_force_png_filter = CGlobalDataFactory.forSymbol("stbi_write_force_png_filter"); 25 | // Actually a function pointer variable, but pointer is pointer, I guess 26 | public static final CGlobalData stbi_zlib_compress = CGlobalDataFactory.forSymbol("stbi_zlib_compress"); 27 | public static final CGlobalData stbi_write_tga_with_rle = CGlobalDataFactory.forSymbol("stbi_write_tga_with_rle"); 28 | 29 | @CFunction 30 | public static native int stbi_write_png_to_func(/*STBIWriteCallbackI*/ PointerBase func, VoidPointer context, int w, int h, int comp, CCharPointer data, int stride_in_bytes); 31 | } 32 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/java/de/kb1000/mcimage/util/stb/STBVorbisSVM.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util.stb; 10 | 11 | import org.graalvm.nativeimage.c.CContext; 12 | import org.graalvm.nativeimage.c.function.CFunction; 13 | import org.graalvm.nativeimage.c.type.CCharPointer; 14 | import org.graalvm.nativeimage.c.type.CIntPointer; 15 | import org.graalvm.word.PointerBase; 16 | 17 | @CContext(LibSTBDirectives.class) 18 | public class STBVorbisSVM { 19 | // This uses a C wrapper function 20 | @CFunction 21 | public static native void nstb_vorbis_get_info(/*STBVorbis*/PointerBase f, /*STBVorbisInfo*/PointerBase __result); 22 | 23 | @CFunction 24 | public static native int stb_vorbis_get_error(/*STBVorbis*/PointerBase f); 25 | 26 | @CFunction 27 | public static native void stb_vorbis_close(/*STBVorbis*/PointerBase f); 28 | 29 | @CFunction 30 | public static native /*STBVorbis*/PointerBase stb_vorbis_open_pushdata(CCharPointer datablock, int datablock_length_in_bytes, CIntPointer datablock_memory_consumed_in_bytes, CIntPointer error, /*STBVorbisAlloc*/PointerBase alloc_buffer); 31 | 32 | @CFunction 33 | public static native int stb_vorbis_decode_frame_pushdata(/*STBVorbis*/PointerBase f, CCharPointer datablock, int datablock_length_in_bytes, CIntPointer channels, /*float *** */ PointerBase output, CIntPointer samples); 34 | } 35 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/resources/META-INF/native-image/reflect-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "java.lang.Integer", 4 | "methods": [ 5 | { 6 | "name": "valueOf", 7 | "parameterTypes": [ 8 | "java.lang.String" 9 | ] 10 | } 11 | ] 12 | }, 13 | { 14 | "name": "java.io.File", 15 | "methods": [ 16 | { 17 | "name": "", 18 | "parameterTypes": [ 19 | "java.lang.String" 20 | ] 21 | } 22 | ] 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /mc-image-lib/src/main/resources/META-INF/native-image/resource-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "resources": { 3 | "includes": [ 4 | { 5 | "pattern": "\\Qoshi.architecture.properties\\E", 6 | "$comment": "TODO: move to build time" 7 | }, 8 | { 9 | "pattern": "\\Qversion.json\\E", 10 | "$comment": "TODO: move to build time" 11 | }, 12 | { 13 | "pattern": "\\Qyggdrasil_session_pubkey.der\\E", 14 | "$comment": "TODO: move to build time" 15 | }, 16 | { 17 | "pattern": "(assets|data)/.*" 18 | } 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/target/commons/Target_org_apache_commons_io_Java7Support.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.commons; 10 | 11 | import com.oracle.svm.core.annotate.Substitute; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | 14 | import java.io.File; 15 | import java.io.IOException; 16 | import java.nio.file.Files; 17 | 18 | @TargetClass(className = "org.apache.commons.io.Java7Support") 19 | @Substitute 20 | final class Target_org_apache_commons_io_Java7Support { 21 | @Substitute 22 | static boolean isSymLink(File file) { 23 | return Files.isSymbolicLink(file.toPath()); 24 | } 25 | 26 | @Substitute 27 | static File readSymbolicLink(File symlink) throws IOException { 28 | return Files.readSymbolicLink(symlink.toPath()).toFile(); 29 | } 30 | 31 | @Substitute 32 | static boolean exists(File file) { 33 | return Files.exists(file.toPath()); 34 | } 35 | 36 | @Substitute 37 | static File createSymbolicLink(File symlink, File target) throws IOException { 38 | if (!exists(symlink)) { 39 | return Files.createSymbolicLink(symlink.toPath(), target.toPath()).toFile(); 40 | } 41 | return symlink; 42 | } 43 | 44 | @Substitute 45 | static void delete(File file) throws IOException { 46 | Files.delete(file.toPath()); 47 | } 48 | 49 | @Substitute 50 | static boolean isAtLeastJava7() { 51 | return true; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/target/gson/Target_com_google_gson_internal_UnsafeAllocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.gson; 10 | 11 | import com.google.gson.internal.UnsafeAllocator; 12 | import com.oracle.svm.core.annotate.AutomaticFeature; 13 | import com.oracle.svm.core.annotate.Substitute; 14 | import com.oracle.svm.core.annotate.TargetClass; 15 | import org.graalvm.nativeimage.ImageSingletons; 16 | import org.graalvm.nativeimage.hosted.Feature; 17 | 18 | @TargetClass(UnsafeAllocator.class) 19 | final class Target_com_google_gson_internal_UnsafeAllocator { 20 | @Substitute 21 | static UnsafeAllocator create() { 22 | return ImageSingletons.lookup(UnsafeAllocator.class); 23 | } 24 | } 25 | 26 | @AutomaticFeature 27 | final class UnsafeAllocatorFeature implements Feature { 28 | @Override 29 | public void duringSetup(DuringSetupAccess access) { 30 | UnsafeAllocator allocator = UnsafeAllocator.create(); 31 | ImageSingletons.add(UnsafeAllocator.class, allocator); 32 | access.registerObjectReplacer(object -> object instanceof UnsafeAllocator ? allocator : object); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/target/jdk/JCEKSDisableFeature.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.jdk; 10 | 11 | import com.oracle.svm.core.annotate.AutomaticFeature; 12 | import com.sun.crypto.provider.SunJCE; 13 | import de.kb1000.mcimage.util.HostedConstants; 14 | import org.graalvm.nativeimage.Platform; 15 | import org.graalvm.nativeimage.Platforms; 16 | import org.graalvm.nativeimage.hosted.Feature; 17 | 18 | import java.lang.invoke.VarHandle; 19 | import java.security.Provider; 20 | import java.security.Security; 21 | import java.util.Map; 22 | 23 | // This keystore type is not used at runtime 24 | @AutomaticFeature 25 | public class JCEKSDisableFeature implements Feature { 26 | @Platforms(Platform.HOSTED_ONLY.class) 27 | static final VarHandle PROVIDER_SERVICE_MAP; 28 | 29 | static { 30 | try { 31 | PROVIDER_SERVICE_MAP = HostedConstants.IMPL_LOOKUP.findVarHandle(Provider.class, "serviceMap", Map.class); 32 | } catch (NoSuchFieldException | IllegalAccessException e) { 33 | throw new RuntimeException(e); 34 | } 35 | } 36 | 37 | @Override 38 | public void duringSetup(DuringSetupAccess access) { 39 | access.registerObjectReplacer(o -> { 40 | if (o instanceof SunJCE jce) { 41 | @SuppressWarnings("unchecked") 42 | Map serviceMap = (Map) PROVIDER_SERVICE_MAP.get(jce); 43 | serviceMap.replaceAll((o1, service) -> service.getAlgorithm().equals("JCEKS") 44 | ? Security.getProvider("SUN").getService("KeyStore", "JKS") 45 | : service); 46 | } 47 | return o; 48 | }); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/target/jdk/Target_com_oracle_svm_core_jdk_TrustStoreManagerSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.jdk; 10 | 11 | import com.oracle.svm.core.annotate.AlwaysInline; 12 | import com.oracle.svm.core.annotate.Substitute; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | 15 | @TargetClass(className = "com.oracle.svm.core.jdk.TrustStoreManagerSupport") 16 | final class Target_com_oracle_svm_core_jdk_TrustStoreManagerSupport { 17 | @Substitute 18 | @AlwaysInline("") 19 | static Target_sun_security_ssl_TrustStoreManager_TrustStoreDescriptor getRuntimeTrustStoreDescriptor() { 20 | return null; 21 | } 22 | } 23 | 24 | @TargetClass(className = "sun.security.ssl.TrustStoreManager", innerClass = "TrustStoreDescriptor") 25 | final class Target_sun_security_ssl_TrustStoreManager_TrustStoreDescriptor { 26 | } 27 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/target/jdk/Target_com_sun_crypto_provider_JceKeyStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.jdk; 10 | 11 | import com.oracle.svm.core.annotate.Delete; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | import com.sun.crypto.provider.JceKeyStore; 14 | 15 | @TargetClass(JceKeyStore.class) 16 | @Delete 17 | final class Target_com_sun_crypto_provider_JceKeyStore { 18 | } 19 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/target/jdk/Target_java_io_ObjectInputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.jdk; 10 | 11 | import com.oracle.svm.core.annotate.Delete; 12 | import com.oracle.svm.core.annotate.TargetClass; 13 | 14 | @TargetClass(className = "java.io.ObjectInputStream") 15 | @Delete 16 | final class Target_java_io_ObjectInputStream { 17 | @TargetClass(className = "java.io.ObjectInputStream", innerClass = "GetField") 18 | @Delete 19 | static final class Target_GetField {} 20 | } 21 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/target/jdk/Target_java_lang_invoke_VarHandleByteArrayAsInts_ByteArrayViewVarHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.jdk; 10 | 11 | /*@TargetClass(className = "java.lang.invoke.VarHandleByteArrayAsInts$ByteArrayViewVarHandle") 12 | @Delete 13 | final class Target_java_lang_invoke_VarHandleByteArrayAsInts_ByteArrayViewVarHandle { 14 | }*/ 15 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/target/jdk/VarHandleByteArrayAccessFeature.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.jdk; 10 | 11 | /*@AutomaticFeature 12 | public class VarHandleByteArrayAccessFeature implements InternalFeature { 13 | @Override 14 | public void registerGraphBuilderPlugins(Providers providers, GraphBuilderConfiguration.Plugins plugins, ParsingReason reason) { 15 | plugins.appendInlineInvokePlugin(new InlineInvokePlugin() { 16 | @Override 17 | public InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) { 18 | String className = method.getDeclaringClass().getUnqualifiedName(); 19 | if ((className.startsWith("VarHandleByte") || className.startsWith("VarHandleReferences")) && (method.getName().startsWith("set") || method.getName().startsWith("get") || method.getName().startsWith("compare") || method.getName().startsWith("weak"))) { 20 | return InlineInfo.createStandardInlineInfo(method); 21 | } 22 | return null; 23 | } 24 | }); 25 | } 26 | }*/ 27 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/target/logging/Target_io_netty_util_internal_logging_InternalLoggerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.logging; 10 | 11 | import com.oracle.svm.core.annotate.AutomaticFeature; 12 | import com.oracle.svm.core.annotate.Substitute; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | import io.netty.util.internal.logging.InternalLoggerFactory; 15 | import org.graalvm.nativeimage.ImageSingletons; 16 | import org.graalvm.nativeimage.hosted.Feature; 17 | 18 | @TargetClass(InternalLoggerFactory.class) 19 | final class Target_io_netty_util_internal_logging_InternalLoggerFactory { 20 | @Substitute 21 | static InternalLoggerFactory getDefaultFactory() { 22 | return ImageSingletons.lookup(InternalLoggerFactory.class); 23 | } 24 | } 25 | 26 | @AutomaticFeature 27 | final class InternalLoggerFactoryFeature implements Feature { 28 | @Override 29 | public void duringSetup(DuringSetupAccess access) { 30 | ImageSingletons.add(InternalLoggerFactory.class, InternalLoggerFactory.getDefaultFactory()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/target/logging/Target_org_apache_commons_logging_LogFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.target.logging; 10 | 11 | import com.oracle.svm.core.annotate.AutomaticFeature; 12 | import com.oracle.svm.core.annotate.Substitute; 13 | import com.oracle.svm.core.annotate.TargetClass; 14 | import org.apache.commons.logging.LogFactory; 15 | import org.graalvm.nativeimage.ImageSingletons; 16 | import org.graalvm.nativeimage.hosted.Feature; 17 | 18 | @TargetClass(LogFactory.class) 19 | final class Target_org_apache_commons_logging_LogFactory { 20 | @Substitute 21 | static LogFactory getFactory() { 22 | return ImageSingletons.lookup(LogFactory.class); 23 | } 24 | } 25 | 26 | @AutomaticFeature 27 | final class LogFactoryFeature implements Feature { 28 | @Override 29 | public void duringSetup(DuringSetupAccess access) { 30 | ImageSingletons.add(LogFactory.class, LogFactory.getFactory()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/util/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util; 10 | 11 | /*public class Constants { 12 | public static final StackWalker GET_CALLER_CLASS_STACKWALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); 13 | }*/ 14 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/util/GLFWAlias.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util; 10 | 11 | import org.lwjgl.glfw.GLFW; 12 | 13 | public class GLFWAlias { 14 | public static final int GLFW_RAW_MOUSE_MOTION = GLFW.GLFW_RAW_MOUSE_MOTION; 15 | } 16 | -------------------------------------------------------------------------------- /mc-image-lib/src/optimize/java/de/kb1000/mcimage/util/ThrowableUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.util; 10 | 11 | import org.jetbrains.annotations.Contract; 12 | 13 | @SuppressWarnings("unchecked") 14 | public class ThrowableUtil { 15 | @Contract(value = "_ -> fail", pure = true) 16 | public static RuntimeException sneakyThrow(Throwable t) throws T { 17 | throw (T) t; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mc-image-substgen/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | plugins { 10 | id("org.jetbrains.kotlin.jvm") version "1.7.10" 11 | } 12 | 13 | repositories { 14 | mavenCentral() 15 | maven(url = "https://libraries.minecraft.net/") { 16 | name = "Minecraft" 17 | metadataSources { 18 | artifact() 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation(project(":mc-image-lib", configuration = "graal")) 25 | implementation(project(":mc-image-lib", configuration = "minecraftLibraries")) 26 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") { 27 | exclude(module = "kotlin-stdlib-common") 28 | } 29 | implementation("org.jetbrains:annotations:23.0.0") 30 | implementation("com.squareup:javapoet:1.13.0") 31 | implementation("jakarta.xml.bind:jakarta.xml.bind-api:4.0.0") 32 | implementation("org.ow2.asm:asm-commons:9.3") 33 | runtimeOnly("org.glassfish.jaxb:jaxb-runtime:4.0.0") 34 | runtimeOnly("org.glassfish.jaxb:jaxb-xjc:4.0.0") 35 | } 36 | -------------------------------------------------------------------------------- /mc-image-substgen/src/main/java/de/kb1000/mcimage/substgen/jaxb/Alias.java: -------------------------------------------------------------------------------- 1 | 2 | package de.kb1000.mcimage.substgen.jaxb; 3 | 4 | import jakarta.xml.bind.annotation.XmlAccessType; 5 | import jakarta.xml.bind.annotation.XmlAccessorType; 6 | import jakarta.xml.bind.annotation.XmlAttribute; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlSchemaType; 9 | import jakarta.xml.bind.annotation.XmlType; 10 | 11 | 12 | /** 13 | *

Java class for anonymous complex type. 14 | * 15 | *

The following schema fragment specifies the expected content contained within this class. 16 | * 17 | *

18 |  * <complexType>
19 |  *   <complexContent>
20 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
21 |  *       <attGroup ref="{}Name"/>
22 |  *     </restriction>
23 |  *   </complexContent>
24 |  * </complexType>
25 |  * 
26 | * 27 | * 28 | */ 29 | @XmlAccessorType(XmlAccessType.FIELD) 30 | @XmlType(name = "") 31 | @XmlRootElement(name = "alias") 32 | public class Alias { 33 | 34 | @XmlAttribute(name = "name", required = true) 35 | @XmlSchemaType(name = "anySimpleType") 36 | protected String name; 37 | 38 | /** 39 | * Gets the value of the name property. 40 | * 41 | * @return 42 | * possible object is 43 | * {@link String } 44 | * 45 | */ 46 | public String getName() { 47 | return name; 48 | } 49 | 50 | /** 51 | * Sets the value of the name property. 52 | * 53 | * @param value 54 | * allowed object is 55 | * {@link String } 56 | * 57 | */ 58 | public void setName(String value) { 59 | this.name = value; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /mc-image-substgen/src/main/java/de/kb1000/mcimage/substgen/jaxb/Extensions.java: -------------------------------------------------------------------------------- 1 | 2 | package de.kb1000.mcimage.substgen.jaxb; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import jakarta.xml.bind.annotation.XmlAccessType; 7 | import jakarta.xml.bind.annotation.XmlAccessorType; 8 | import jakarta.xml.bind.annotation.XmlRootElement; 9 | import jakarta.xml.bind.annotation.XmlType; 10 | 11 | 12 | /** 13 | *

Java class for anonymous complex type. 14 | * 15 | *

The following schema fragment specifies the expected content contained within this class. 16 | * 17 | *

18 |  * <complexType>
19 |  *   <complexContent>
20 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
21 |  *       <sequence>
22 |  *         <element ref="{}extension" maxOccurs="unbounded" minOccurs="0"/>
23 |  *       </sequence>
24 |  *     </restriction>
25 |  *   </complexContent>
26 |  * </complexType>
27 |  * 
28 | * 29 | * 30 | */ 31 | @XmlAccessorType(XmlAccessType.FIELD) 32 | @XmlType(name = "", propOrder = { 33 | "extension" 34 | }) 35 | @XmlRootElement(name = "extensions") 36 | public class Extensions { 37 | 38 | protected List extension; 39 | 40 | /** 41 | * Gets the value of the extension property. 42 | * 43 | *

44 | * This accessor method returns a reference to the live list, 45 | * not a snapshot. Therefore any modification you make to the 46 | * returned list will be present inside the Jakarta XML Binding object. 47 | * This is why there is not a set method for the extension property. 48 | * 49 | *

50 | * For example, to add a new item, do as follows: 51 | *

52 |      *    getExtension().add(newItem);
53 |      * 
54 | * 55 | * 56 | *

57 | * Objects of the following type(s) are allowed in the list 58 | * {@link Extension } 59 | * 60 | * 61 | */ 62 | public List getExtension() { 63 | if (extension == null) { 64 | extension = new ArrayList(); 65 | } 66 | return this.extension; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /mc-image-substgen/src/main/java/de/kb1000/mcimage/substgen/jaxb/Groups.java: -------------------------------------------------------------------------------- 1 | 2 | package de.kb1000.mcimage.substgen.jaxb; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import jakarta.xml.bind.annotation.XmlAccessType; 7 | import jakarta.xml.bind.annotation.XmlAccessorType; 8 | import jakarta.xml.bind.annotation.XmlRootElement; 9 | import jakarta.xml.bind.annotation.XmlType; 10 | 11 | 12 | /** 13 | *

Java class for anonymous complex type. 14 | * 15 | *

The following schema fragment specifies the expected content contained within this class. 16 | * 17 | *

18 |  * <complexType>
19 |  *   <complexContent>
20 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
21 |  *       <sequence>
22 |  *         <element ref="{}group" maxOccurs="unbounded" minOccurs="0"/>
23 |  *       </sequence>
24 |  *     </restriction>
25 |  *   </complexContent>
26 |  * </complexType>
27 |  * 
28 | * 29 | * 30 | */ 31 | @XmlAccessorType(XmlAccessType.FIELD) 32 | @XmlType(name = "", propOrder = { 33 | "group" 34 | }) 35 | @XmlRootElement(name = "groups") 36 | public class Groups { 37 | 38 | protected List group; 39 | 40 | /** 41 | * Gets the value of the group property. 42 | * 43 | *

44 | * This accessor method returns a reference to the live list, 45 | * not a snapshot. Therefore any modification you make to the 46 | * returned list will be present inside the Jakarta XML Binding object. 47 | * This is why there is not a set method for the group property. 48 | * 49 | *

50 | * For example, to add a new item, do as follows: 51 | *

52 |      *    getGroup().add(newItem);
53 |      * 
54 | * 55 | * 56 | *

57 | * Objects of the following type(s) are allowed in the list 58 | * {@link Group } 59 | * 60 | * 61 | */ 62 | public List getGroup() { 63 | if (group == null) { 64 | group = new ArrayList(); 65 | } 66 | return this.group; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /mc-image-substgen/src/main/java/de/kb1000/mcimage/substgen/jaxb/Vecequiv.java: -------------------------------------------------------------------------------- 1 | 2 | package de.kb1000.mcimage.substgen.jaxb; 3 | 4 | import jakarta.xml.bind.annotation.XmlAccessType; 5 | import jakarta.xml.bind.annotation.XmlAccessorType; 6 | import jakarta.xml.bind.annotation.XmlAttribute; 7 | import jakarta.xml.bind.annotation.XmlRootElement; 8 | import jakarta.xml.bind.annotation.XmlSchemaType; 9 | import jakarta.xml.bind.annotation.XmlType; 10 | 11 | 12 | /** 13 | *

Java class for anonymous complex type. 14 | * 15 | *

The following schema fragment specifies the expected content contained within this class. 16 | * 17 | *

18 |  * <complexType>
19 |  *   <complexContent>
20 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
21 |  *       <attGroup ref="{}Name"/>
22 |  *     </restriction>
23 |  *   </complexContent>
24 |  * </complexType>
25 |  * 
26 | * 27 | * 28 | */ 29 | @XmlAccessorType(XmlAccessType.FIELD) 30 | @XmlType(name = "") 31 | @XmlRootElement(name = "vecequiv") 32 | public class Vecequiv { 33 | 34 | @XmlAttribute(name = "name", required = true) 35 | @XmlSchemaType(name = "anySimpleType") 36 | protected String name; 37 | 38 | /** 39 | * Gets the value of the name property. 40 | * 41 | * @return 42 | * possible object is 43 | * {@link String } 44 | * 45 | */ 46 | public String getName() { 47 | return name; 48 | } 49 | 50 | /** 51 | * Sets the value of the name property. 52 | * 53 | * @param value 54 | * allowed object is 55 | * {@link String } 56 | * 57 | */ 58 | public void setName(String value) { 59 | this.name = value; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /mc-image-substgen/src/main/kotlin/de/kb1000/mcimage/substgen/GeneratePatchedSharedSecrets.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.substgen 10 | 11 | import org.objectweb.asm.ClassReader 12 | import org.objectweb.asm.ClassVisitor 13 | import org.objectweb.asm.ClassWriter 14 | import org.objectweb.asm.FieldVisitor 15 | import org.objectweb.asm.Opcodes.ASM9 16 | import java.io.InputStream 17 | import java.util.* 18 | import kotlin.io.path.createDirectories 19 | import kotlin.io.path.div 20 | import kotlin.io.path.writeBytes 21 | 22 | fun generatePatchedSharedSecrets() { 23 | val targetFile = jdkPatchTargetDir / "jdk" / "internal" / "access" / "SharedSecrets.class" 24 | targetFile.parent.createDirectories() 25 | 26 | val classReader = TreeMap::class.java.module.getResourceAsStream("jdk/internal/access/SharedSecrets.class").use(::ClassReader) 27 | val classWriter = ClassWriter(classReader, ClassWriter.COMPUTE_FRAMES) 28 | classReader.accept(object : ClassVisitor(ASM9, classWriter) { 29 | override fun visitField( 30 | access: Int, 31 | name: String, 32 | descriptor: String, 33 | signature: String?, 34 | value: Any? 35 | ): FieldVisitor? { 36 | val fv = super.visitField(access, name, descriptor, signature, value) ?: return null 37 | fv.visitAnnotation("Ljdk/internal/vm/annotation/Stable;", true)?.visitEnd() 38 | return fv 39 | } 40 | }, 0) 41 | targetFile.writeBytes(classWriter.toByteArray()) 42 | } -------------------------------------------------------------------------------- /mc-image-substgen/src/main/kotlin/de/kb1000/mcimage/substgen/Main.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | @file:JvmName("Main") 10 | 11 | package de.kb1000.mcimage.substgen 12 | 13 | import java.nio.file.FileSystem 14 | import java.nio.file.FileSystems 15 | import kotlin.io.path.Path 16 | import kotlin.io.path.toPath 17 | import kotlin.reflect.KClass 18 | 19 | fun openJar(c: KClass<*>): FileSystem = 20 | FileSystems.newFileSystem(c.java.protectionDomain.codeSource.location.toURI().toPath()) 21 | 22 | var targetDir = Path("mc-image-lib", "gen") 23 | 24 | fun main(args: Array) { 25 | if (args.isNotEmpty()) 26 | targetDir = Path(args[0]) 27 | generateJNIInvokerSubstitution() 28 | generateCallbackBackend() 29 | generateGLInvokers() 30 | generatePatchedTreeMap() 31 | generatePatchedSharedSecrets() 32 | } 33 | -------------------------------------------------------------------------------- /mc-image-substgen/src/main/kotlin/de/kb1000/mcimage/substgen/Util.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 kb1000. 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | package de.kb1000.mcimage.substgen 10 | 11 | import com.squareup.javapoet.AnnotationSpec 12 | import com.squareup.javapoet.ClassName 13 | import com.squareup.javapoet.TypeName 14 | import kotlin.reflect.KClass 15 | 16 | fun AnnotationSpec.Builder.addMember(name: String, type: TypeName): AnnotationSpec.Builder = 17 | addMember(name, "\$T.class", type) 18 | 19 | fun AnnotationSpec.Builder.addMember(name: String, clazz: Class<*>): AnnotationSpec.Builder = 20 | addMember(name, ClassName.get(clazz)) 21 | 22 | inline fun AnnotationSpec.Builder.addMember(name: String, clazz: KClass<*>): AnnotationSpec.Builder = 23 | addMember(name, clazz.java) 24 | 25 | fun AnnotationSpec.Builder.addMember(name: String, enum: Enum<*>): AnnotationSpec.Builder = 26 | addMember(name, "\$T.\$L", enum.javaClass, enum.name) 27 | -------------------------------------------------------------------------------- /mc-image.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /minecraft-client-gdb.gdb: -------------------------------------------------------------------------------- 1 | break sources/com/oracle/svm/core/classinitialization/ClassInitializationInfo.java:304 2 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright (c) 2021-2022 kb1000. 4 | # 5 | # This Source Code Form is subject to the terms of the Mozilla Public 6 | # License, v. 2.0. If a copy of the MPL was not distributed with this 7 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | # 9 | 10 | LD_LIBRARY_PATH=$(realpath natives) 11 | export LD_LIBRARY_PATH 12 | 13 | if TEMP=$(getopt -l 'no-optimize' -o 'g' -- "$@"); then 14 | true 15 | else 16 | echo 'Terminating...' >&2 17 | exit 1 18 | fi 19 | 20 | eval set -- "$TEMP" 21 | unset TEMP 22 | wrapper=() 23 | optimize=true 24 | 25 | while true; do 26 | case "$1" in 27 | '-g') 28 | wrapper=(gdb --args) 29 | shift 30 | continue 31 | ;; 32 | '--no-optimize') 33 | optimize=false 34 | shift 35 | continue 36 | ;; 37 | '--') 38 | shift 39 | break 40 | ;; 41 | *) 42 | echo 'Internal error!' >&2 43 | exit 1 44 | ;; 45 | esac 46 | done 47 | 48 | 49 | exec "${wrapper[@]}" ./minecraft-client$(if ! $optimize; then echo -n -unoptimized; fi) "$@" --version 1.17.1 --accessToken "" --assetIndex 1.17 50 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "mc-image" 2 | 3 | include("mc-image-lib") 4 | include("mc-image-agent") 5 | include("mc-image-substgen") 6 | -------------------------------------------------------------------------------- /stb.c: -------------------------------------------------------------------------------- 1 | #include "lwjgl_malloc.h" 2 | 3 | mallocPROC org_lwjgl_malloc; 4 | callocPROC org_lwjgl_calloc; 5 | reallocPROC org_lwjgl_realloc; 6 | freePROC org_lwjgl_free; 7 | 8 | aligned_allocPROC org_lwjgl_aligned_alloc; 9 | aligned_freePROC org_lwjgl_aligned_free; 10 | 11 | #define STB_IMAGE_IMPLEMENTATION 12 | #define STB_IMAGE_RESIZE_IMPLEMENTATION 13 | #define STB_IMAGE_WRITE_IMPLEMENTATION 14 | #define STB_TRUETYPE_IMPLEMENTATION 15 | #define STB_VORBIS_IMPLEMENTATION 16 | #define STB_RECT_PACK_IMPLEMENTATION 17 | #include "stb.h" 18 | 19 | void nstb_vorbis_get_info(stb_vorbis *f, stb_vorbis_info *__result) { 20 | *__result = stb_vorbis_get_info(f); 21 | } 22 | -------------------------------------------------------------------------------- /stb.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "lwjgl_malloc.h" 4 | 5 | #ifdef __linux__ 6 | #include 7 | #endif 8 | 9 | // only add those used by MC 10 | 11 | #define STBI_MALLOC(sz) org_lwjgl_malloc(sz) 12 | #define STBI_REALLOC(p,sz) org_lwjgl_realloc(p,sz) 13 | #define STBI_FREE(p) org_lwjgl_free(p) 14 | #define STBI_FAILURE_USERMSG 15 | #define STBI_ASSERT(x) 16 | #ifdef LWJGL_WINDOWS 17 | #define STBI_WINDOWS_UTF8 18 | #endif 19 | #include "stb_image.h" 20 | 21 | #define STBIR_MALLOC(size,c) org_lwjgl_malloc(size) 22 | #define STBIR_FREE(ptr,c) org_lwjgl_free(ptr) 23 | #define STBIR_ASSERT(x) 24 | #include "stb_image_resize.h" 25 | 26 | 27 | #define STBIW_MALLOC(sz) org_lwjgl_malloc(sz) 28 | #define STBIW_REALLOC(p,sz) org_lwjgl_realloc(p,sz) 29 | #define STBIW_FREE(p) org_lwjgl_free(p) 30 | #define STBIW_ASSERT(x) 31 | #ifdef LWJGL_WINDOWS 32 | #define STBIW_WINDOWS_UTF8 33 | #define STBI_MSC_SECURE_CRT 34 | #endif 35 | #include "stb_image_write.h" 36 | 37 | #define STBTT_malloc(x,u) ((void)(u),org_lwjgl_malloc(x)) 38 | #define STBTT_free(x,u) ((void)(u),org_lwjgl_free(x)) 39 | #define STBTT_assert 40 | #define STBRP_ASSERT 41 | #include "stb_rect_pack.h" 42 | #include "stb_truetype.h" 43 | 44 | #ifndef STB_VORBIS_IMPLEMENTATION 45 | #define STB_VORBIS_HEADER_ONLY 46 | #endif 47 | #include "stb_vorbis.c" 48 | --------------------------------------------------------------------------------