{"id":40417313,"url":"https://github.com/digitalgust/tinyj2c","last_synced_at":"2026-01-20T14:39:05.162Z","repository":{"id":88236886,"uuid":"290098135","full_name":"digitalgust/tinyj2c","owner":"digitalgust","description":"Convert JAVA source to C source, Build standlone binary without any class file.  ","archived":false,"fork":false,"pushed_at":"2023-11-08T08:25:51.000Z","size":2153,"stargazers_count":43,"open_issues_count":2,"forks_count":8,"subscribers_count":7,"default_branch":"master","last_synced_at":"2023-11-08T10:31:38.584Z","etag":null,"topics":["embeddeddevice","j2c","java2c"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitalgust.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-08-25T03:02:23.000Z","updated_at":"2023-11-03T21:24:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"c174325f-4716-43f8-954f-cf919c04b342","html_url":"https://github.com/digitalgust/tinyj2c","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/digitalgust/tinyj2c","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalgust%2Ftinyj2c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalgust%2Ftinyj2c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalgust%2Ftinyj2c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalgust%2Ftinyj2c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalgust","download_url":"https://codeload.github.com/digitalgust/tinyj2c/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalgust%2Ftinyj2c/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28605110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T12:01:53.233Z","status":"ssl_error","status_checked_at":"2026-01-20T12:01:46.545Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embeddeddevice","j2c","java2c"],"created_at":"2026-01-20T14:39:05.090Z","updated_at":"2026-01-20T14:39:05.156Z","avatar_url":"https://github.com/digitalgust.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Tinyj2c\n\nTinyj2c transfer JAVA source to C source, build as standlone binary, and run without any class file. It's so small can be used to embedded device.\n\n# Feature  \n* A very very small java runtime    \n* Garbage collection  \n* Minimize memory footprint   \n* Exception stack trace    \n* Thread support  \n* Lambda support  \n\n    \n# Requirement \n1. JDK 8+ (not only jre).         \n2. clang/gcc/vsc.     \n   win i686 download:  https://github.com/digitalgust/mingw-w64/releases/download/release/i686-8.1.0-release-posix-dwarf-rt_v6-rev0.7z    \n   win x64 download:   https://github.com/digitalgust/mingw-w64/releases/download/release/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z    \n     \n# Steps    \n \n* run build script :    \n /tinyj2c/posix_build.sh   \n\nOr \n\n* git clone https://github.com/digitalgust/tinyj2c.git        \n* Idea open /tinyj2c/class2c , run translator.    \n* Clion/vs/xcode open /tinyj2c/app , compile c source and run .      \n* Run binary no java classes dependence.   \n\n     \n# Translated java file Example   \n    \n* Java code:\n\n```\npackage test;\n\npublic class HelloWorld {\n    static String str = \"Hello world!\";\n\n    void test() throws RuntimeException {\n        try {\n            System.out.println(str);\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n\n    public static void main(String args[]) {\n        new HelloWorld().test();\n    }\n}\n```     \n     \n* converted C code:     \n     \n```     \n// CLASS: test/HelloWorld extends java/lang/Object\n#include \"metadata.h\"\n\n\n// generation\n// globals\n//struct test_HelloWorld_static {struct java_lang_String* str_0;  };\nstruct test_HelloWorld_static static_var_test_HelloWorld = {NULL};\n\n\n__refer arr_vmtable_test_HelloWorld_from_test_HelloWorld[] = {\n    func_test_HelloWorld_test___V  //0\n};\n__refer arr_vmtable_test_HelloWorld_from_java_lang_Object[] = {\n    func_java_lang_Object_toString___Ljava_lang_String_2,  //0\n    func_java_lang_Object_wait___V,  //1\n    func_java_lang_Object_finalize___V,  //2\n    func_java_lang_Object_equals__Ljava_lang_Object_2_Z,  //3\n    func_java_lang_Object_clone___Ljava_lang_Object_2,  //4\n    func_java_lang_Object_getClass___Ljava_lang_Class_2,  //5\n    func_java_lang_Object_wait__J_V,  //6\n    func_java_lang_Object_notify___V,  //7\n    func_java_lang_Object_notifyAll___V,  //8\n    func_java_lang_Object_hashCode___I  //9\n};\nVMTable vmtable_test_HelloWorld[] = {\n    {147, 1, arr_vmtable_test_HelloWorld_from_test_HelloWorld}, //0\n    {5, 10, arr_vmtable_test_HelloWorld_from_java_lang_Object}, //1\n};\n\n\n\n// locals: 1\n// stack: 1\n// args: 1\nvoid func_test_HelloWorld__init____V(JThreadRuntime *runtime, struct test_HelloWorld* p0){\n    \n    StackItem local[1] = {0};\n    RStackItem rlocal[1] = {0};\n    StackItem stack[2];\n    RStackItem rstack[2];\n    s32 sp = 0;\n    StackFrame *__frame = method_enter(runtime, 1207, \u0026rstack[0], \u0026rlocal[0], \u0026sp);\n    rlocal[0].obj = p0;\n    ; \n    //  line no 3 , L1842355195 , bytecode index = 0\n    __frame-\u003ebytecodeIndex = 0; //first\n    __frame-\u003elineNo = 3;\n    rstack[sp++].obj = rlocal[0].obj;\n    // invokespecial java/lang/Object.\u003cinit\u003e()V\n    sp -= 1;  //pop para\n    // it's a empty method\n    method_exit(runtime);\n    return;\n    ; \n    __ExceptionHandler:\n    switch (find_exception_handler_index(runtime)) {\n        default: goto __ExceptionHandlerNotFound;\n    }\n    __ExceptionHandlerNotFound:\n    method_exit(runtime);\n    return ;\n}\n\nvoid bridge_test_HelloWorld__init____V(JThreadRuntime *runtime, __refer ins, ParaItem *para, ParaItem *ret) {\n    func_test_HelloWorld__init____V(runtime, ins);\n}\n\nExceptionItem arr_extable_func_test_HelloWorld_test___V[] = {\n    { 0, 9, 130}\n};\nExceptionTable extable_func_test_HelloWorld_test___V = {1, arr_extable_func_test_HelloWorld_test___V};\n\n// locals: 2\n// stack: 2\n// args: 1\nvoid func_test_HelloWorld_test___V(JThreadRuntime *runtime, struct test_HelloWorld* p0){\n    \n    StackItem local[2] = {0};\n    RStackItem rlocal[2] = {0};\n    StackItem stack[3];\n    RStackItem rstack[3];\n    s32 sp = 0;\n    StackFrame *__frame = method_enter(runtime, 1208, \u0026rstack[0], \u0026rlocal[0], \u0026sp);\n    rlocal[0].obj = p0;\n    // try catch :L389748355 L944266478 L1437243359 (0,9)-\u003e12\n    L389748355:\n    __frame-\u003ebytecodeIndex = 0; //try catch begin\n    //  line no 8 , L389748355 , bytecode index = 0\n    __frame-\u003ebytecodeIndex = 0; //first\n    __frame-\u003elineNo = 8;\n    // getstatic java/lang/System out Ljava/io/PrintStream;\n    rstack[sp].obj =static_var_java_lang_System.out_2;\n    sp += 1;\n    // getstatic test/HelloWorld str Ljava/lang/String;\n    rstack[sp].obj =static_var_test_HelloWorld.str_0;\n    sp += 1;\n    // invokevirtual java/io/PrintStream.println(Ljava/lang/String;)V\n    {\n        sp -= 2;\n        JObject *__ins = rstack[sp + 0].ins;\n        if (!__ins) {\n            rstack[sp++].obj = construct_and_throw_exception(runtime, 0, 0, 8);\n            goto __ExceptionHandler;\n        }\n        void (*__func_p) (JThreadRuntime *,struct java_io_PrintStream*,struct java_lang_String*) = find_method(__ins-\u003evm_table, 19, 4);\n        __func_p(runtime, rstack[sp + 0].obj, rstack[sp + 1].obj);\n        sp += 0;\n        if (runtime-\u003eexception) {\n            rstack[sp++].obj = runtime-\u003eexception;\n            goto __ExceptionHandler;\n        }\n    }\n    L944266478:\n    __frame-\u003ebytecodeIndex = 9; //try catch end\n    //  line no 11 , L944266478 , bytecode index = 9\n    goto L1959940703;\n    L1437243359:\n    //  line no 9 , L1437243359 , bytecode index = 12\n    rlocal[1].obj = rstack[--sp].obj;\n    ; \n    //  line no 10 , L999480648 , bytecode index = 13\n    rstack[sp++].obj = rlocal[1].obj;\n    // invokevirtual java/lang/Exception.printStackTrace()V\n    {\n        sp -= 1;\n        JObject *__ins = rstack[sp + 0].ins;\n        if (!__ins) {\n            rstack[sp++].obj = construct_and_throw_exception(runtime, 0, 13, 10);\n            goto __ExceptionHandler;\n        }\n        void (*__func_p) (JThreadRuntime *,struct java_lang_Throwable*) = find_method(__ins-\u003evm_table, 18, 4);\n        __func_p(runtime, rstack[sp + 0].obj);\n        sp += 0;\n        if (runtime-\u003eexception) {\n            rstack[sp++].obj = runtime-\u003eexception;\n            goto __ExceptionHandler;\n        }\n    }\n    L1959940703:\n    //  line no 12 , L1959940703 , bytecode index = 17\n    method_exit(runtime);\n    return;\n    ; \n    __ExceptionHandler:\n    switch (find_exception_handler_index(runtime)) {\n        case 0 : goto L1437243359;\n        default: goto __ExceptionHandlerNotFound;\n    }\n    __ExceptionHandlerNotFound:\n    method_exit(runtime);\n    return ;\n}\n\nvoid bridge_test_HelloWorld_test___V(JThreadRuntime *runtime, __refer ins, ParaItem *para, ParaItem *ret) {\n    func_test_HelloWorld_test___V(runtime, ins);\n}\n\n\n// locals: 1\n// stack: 2\n// args: 1\nvoid func_test_HelloWorld_main___3Ljava_lang_String_2_V(JThreadRuntime *runtime, JArray * p0){\n    \n    StackItem local[1] = {0};\n    RStackItem rlocal[1] = {0};\n    StackItem stack[3];\n    RStackItem rstack[3];\n    s32 sp = 0;\n    StackFrame *__frame = method_enter(runtime, 1209, \u0026rstack[0], \u0026rlocal[0], \u0026sp);\n    rlocal[0].obj = p0;\n    ; \n    //  line no 15 , L1087515232 , bytecode index = 0\n    __frame-\u003ebytecodeIndex = 0; //first\n    __frame-\u003elineNo = 15;\n    // new test/HelloWorld\n    rstack[sp++].obj = new_instance_with_classraw_index(runtime, 147);\n    // dup\n    stack[sp].j = stack[sp - 1].j; \n    rstack[sp].obj = rstack[sp - 1].obj; \n    ++sp;\n    // invokespecial test/HelloWorld.\u003cinit\u003e()V\n    {\n        sp -= 1;\n        JObject *__ins = rstack[sp + 0].ins;\n        if (!__ins) {\n            rstack[sp++].obj = construct_and_throw_exception(runtime, 0, 0, 15);\n            goto __ExceptionHandler;\n        }\n        func_test_HelloWorld__init____V(runtime, rstack[sp + 0].obj);\n        sp += 0;\n        if (runtime-\u003eexception) {\n            rstack[sp++].obj = runtime-\u003eexception;\n            goto __ExceptionHandler;\n        }\n    }\n    // invokevirtual test/HelloWorld.test()V\n    {\n        sp -= 1;\n        JObject *__ins = rstack[sp + 0].ins;\n        if (!__ins) {\n            rstack[sp++].obj = construct_and_throw_exception(runtime, 0, 0, 15);\n            goto __ExceptionHandler;\n        }\n        void (*__func_p) (JThreadRuntime *,struct test_HelloWorld*) = find_method(__ins-\u003evm_table, 147, 0);\n        __func_p(runtime, rstack[sp + 0].obj);\n        sp += 0;\n        if (runtime-\u003eexception) {\n            rstack[sp++].obj = runtime-\u003eexception;\n            goto __ExceptionHandler;\n        }\n    }\n    ; \n    //  line no 16 , L645187727 , bytecode index = 10\n    method_exit(runtime);\n    return;\n    ; \n    __ExceptionHandler:\n    switch (find_exception_handler_index(runtime)) {\n        default: goto __ExceptionHandlerNotFound;\n    }\n    __ExceptionHandlerNotFound:\n    method_exit(runtime);\n    return ;\n}\n\nvoid bridge_test_HelloWorld_main___3Ljava_lang_String_2_V(JThreadRuntime *runtime, __refer ins, ParaItem *para, ParaItem *ret) {\n    func_test_HelloWorld_main___3Ljava_lang_String_2_V(runtime, para[0].obj);\n}\n\n\n// locals: 0\n// stack: 1\n// args: 0\nvoid func_test_HelloWorld__clinit____V(JThreadRuntime *runtime){\n    \n    StackItem stack[2];\n    RStackItem rstack[2];\n    s32 sp = 0;\n    StackFrame *__frame = method_enter(runtime, 1210, \u0026rstack[0], NULL, \u0026sp);\n    ; \n    //  line no 4 , L1892854145 , bytecode index = 0\n    __frame-\u003ebytecodeIndex = 0; //first\n    __frame-\u003elineNo = 4;\n    //  ldc \n    rstack[sp++].obj = construct_string_with_utfraw_index(runtime, 2092);\n    // putstatic test/HelloWorld str Ljava/lang/String;\n    sp -= 1;\n    static_var_test_HelloWorld.str_0 = rstack[sp].obj;\n    method_exit(runtime);\n    return;\n    __ExceptionHandler:\n    switch (find_exception_handler_index(runtime)) {\n        default: goto __ExceptionHandlerNotFound;\n    }\n    __ExceptionHandlerNotFound:\n    method_exit(runtime);\n    return ;\n}\n\nvoid bridge_test_HelloWorld__clinit____V(JThreadRuntime *runtime, __refer ins, ParaItem *para, ParaItem *ret) {\n    func_test_HelloWorld__clinit____V(runtime);\n}\n\n\n\n```     \n     \n## License\n\nLicense:    MIT\n\nGust , digitalgust@163.com .   \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalgust%2Ftinyj2c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalgust%2Ftinyj2c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalgust%2Ftinyj2c/lists"}