{"id":16373630,"url":"https://github.com/deechael/dynamicclassgenerator","last_synced_at":"2025-10-06T13:13:08.179Z","repository":{"id":40349872,"uuid":"482438554","full_name":"DeeChael/DynamicClassGenerator","owner":"DeeChael","description":"Allow you to generate java class when running a program","archived":false,"fork":false,"pushed_at":"2023-10-15T14:48:54.000Z","size":274,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"v2","last_synced_at":"2025-04-04T12:05:48.506Z","etag":null,"topics":["compile","dynamic-programming","java","kotlin","runtime"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DeeChael.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-17T05:46:32.000Z","updated_at":"2023-10-15T03:29:51.000Z","dependencies_parsed_at":"2024-11-02T02:32:01.556Z","dependency_job_id":null,"html_url":"https://github.com/DeeChael/DynamicClassGenerator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DeeChael/DynamicClassGenerator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeeChael%2FDynamicClassGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeeChael%2FDynamicClassGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeeChael%2FDynamicClassGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeeChael%2FDynamicClassGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeeChael","download_url":"https://codeload.github.com/DeeChael/DynamicClassGenerator/tar.gz/refs/heads/v2","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeeChael%2FDynamicClassGenerator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278615601,"owners_count":26016207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["compile","dynamic-programming","java","kotlin","runtime"],"created_at":"2024-10-11T03:14:49.351Z","updated_at":"2025-10-06T13:13:08.132Z","avatar_url":"https://github.com/DeeChael.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ! This Project is reworking under https://www.github.com/DeeChael/dcg ! Check new project! !\n\n# Dynamic Class Generator \n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.deechael/dcg/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.deechael/dcg)\n[![License](https://img.shields.io/github/license/DeeChael/DynamicClassGenerator.svg)](https://www.gnu.org/licenses/gpl-3.0.html)\n[![CodeFactor](https://www.codefactor.io/repository/github/deechael/dynamicclassgenerator/badge)](https://www.codefactor.io/repository/github/theothers-smp-project/dynamicclassgenerator)\n[![Forks](https://img.shields.io/github/forks/DeeChael/DynamicClassGenerator.svg)](https://github.com/DeeChael/DynamicClassGenerator/fork)\n[![Stars](https://img.shields.io/github/stars/DeeChael/DynamicClassGenerator.svg)](https://github.com/DeeChael/DynamicClassGenerator/stargazers)\n## Allow you to generate classes while the program is running!\n\n#### I have made a plan that I will make DCG 2.00.0 for jdk17+\n\n\u003cb\u003eGo to wiki to learn more!\u003c/b\u003e\n\n### Known Issues:\n1. \u003cs\u003eCannot load a class from other class loaders, so even generated the class, maybe it will cause NoDefClassException\u003c/s\u003e\n\n### Importation:\n#### For Maven\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003enet.deechael\u003c/groupId\u003e\n    \u003cartifactId\u003edcg\u003c/artifactId\u003e\n    \u003cversion\u003e1.05.0\u003c/version\u003e\n    \u003cscope\u003ecompile\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n#### For Gradle\n```kotlin\ndependencies { \n    //...\n    implementation 'net.deechael:dcg:1.05.0'\n}\n```\n\n### Example:\n```java\nJClass clazz = new JClass(Level.PUBLIC, \"net.deechael.test\", \"DynamicClassGeneratorTest\");\nJField field = clazz.addField(Level.PUBLIC, JType.classType(String.class), \"parent\", false, false);\nfield.initialize(JStringVar.stringVar(\"aaaaaaaaaaaaaaaaaaaaaaa\"));\nJConstructor constructor = clazz.addConstructor(Level.PUBLIC);\nVar testing = constructor.addParameter(JType.classType(String.class), \"testing\");\nVar human = constructor.addParameter(JType.classType(Human.class), \"human\");\nVar second = constructor.createVar(JType.classType(String.class), \"second\", Var.constructor(JType.classType(String.class), testing));\nVar age = constructor.createVar(JType.classType(int.class), \"age\", Var.invokeMethod(human, \"getAge\"));\nVar name = constructor.createVar(JType.classType(String.class), \"name\", Var.invokeMethod(human, \"getName\"));\nconstructor.invokeMethod(human, \"print\", testing);\nconstructor.invokeMethod(human, \"print\", second);\nconstructor.invokeMethod(human, \"print\", human);\nconstructor.invokeMethod(human, \"print\", age);\nconstructor.invokeMethod(human, \"print\", name);\nconstructor.ifElse(Requirement.isEqual(age, JStringVar.intVar(16)), (executable) -\u003e {\nexecutable.invokeMethod(human, \"print\", JStringVar.stringVar(\"You entered if executable body\"));\n}).setElse(((executable) -\u003e {\nexecutable.invokeMethod(human, \"print\", JStringVar.stringVar(\"You entered else executable body\"));\n}));\n\nJMethod method = clazz.addMethod(Level.PUBLIC, \"testing\", false, false, false);\nVar method_human = method.addParameter(JType.classType(Human.class), \"human\");\nVar method_age = method.createVar(JType.classType(int.class), \"age\", Var.invokeMethod(human, \"getAge\"));\nmethod.invokeMethod(method_human, \"print\", JStringVar.stringVar(\"Method testing\"));\nmethod.ifElse(Requirement.isEqual(method_age, JStringVar.intVar(16)), (executable) -\u003e {\nexecutable.invokeMethod(method_human, \"print\", JStringVar.stringVar(\"Method if body\"));\n}).setElse((executable) -\u003e {\nexecutable.invokeMethod(method_human, \"print\", JStringVar.stringVar(\"Method else body\"));\n});\nmethod.invokeMethod(method_human, \"print\", field);\nmethod.setFieldValue(field, JStringVar.stringVar(\"bbbbbbbbbbbbbbbbbbbb\"));\nmethod.invokeMethod(method_human, \"print\", field);\n\nClass\u003c?\u003e generated = JGenerator.generate(clazz);\nConstructor\u003c?\u003e cons = generated.getConstructor(String.class, Human.class);\nObject instance = cons.newInstance(\"Test message!\", new Human(\"Name\", 16));\ngenerated.getMethod(\"testing\", Human.class).invoke(instance, new Human(\"DeeChael\", 16));\ngenerated.getMethod(\"testing\", Human.class).invoke(instance, new Human(\"DeeChael\", 39));\n```\n\n### Generated code:\n```java\npackage net.deechael.test;\n\nimport java.lang.String;\nimport net.deechael.library.dcg.test.Human;\n\n/**\n * The generated code as you can see is formatted by hand,\n * there is no space at the start of the lines in the real generated code\n */\npublic class DynamicClassGeneratorTest {\n\n    public java.lang.String jfield_parent = (\"aaaaaaaaaaaaaaaaaaaaaaa\");\n\n    public DynamicClassGeneratorTest (java.lang.String jparam_testing, net.deechael.library.dcg.test.Human jparam_human) {\n        java.lang.String jvar_second = new java.lang.String(jparam_testing);\n        int jvar_age = jparam_human.getAge();\n        java.lang.String jvar_name = jparam_human.getName();\n        jparam_human.print(jparam_testing);\n        jparam_human.print(jvar_second);\n        jparam_human.print(jparam_human);\n        jparam_human.print(jvar_age);\n        jparam_human.print(jvar_name);\n        if (jvar_age == 16) {\n            jparam_human.print(\"You entered if executable body\");\n        } else {\n            jparam_human.print(\"You entered else executable body\");\n        }\n    }\n\n    public void testing(net.deechael.library.dcg.test.Human jparam_human) {\n        int jvar_age = jparam_human.getAge();\n        jparam_human.print(\"Method testing\");\n        if (jvar_age == 16) {\n            jparam_human.print(\"Method if body\");\n        } else {\n            jparam_human.print(\"Method else body\");\n        }\n\n        jparam_human.print(this.jfield_parent);\n        this.jfield_parent = (\"bbbbbbbbbbbbbbbbbbbb\");\n        jparam_human.print(this.jfield_parent);\n    }\n\n}\n```\n\n### Coming Soon:\n\n1.\u003cs\u003eExtending class\u003c/s\u003e\\\n2.\u003cs\u003eImplementing interfaces\u003c/s\u003e\\\n3.Creating annotation\\\n4.\u003cs\u003eCreating enum\u003c/s\u003e\\\n5.\u003cs\u003eCreating interface\u003c/s\u003e\\\n6.\u003cs\u003eTry \u0026 Catch\u003c/s\u003e\\\n7.\u003cs\u003eTry \u0026 multi Catch\u003c/s\u003e\\\n8.\u003cs\u003eTry \u0026 1 Catch with multi exceptions\u003c/s\u003e\\\n9.\u003cs\u003eIf \u0026 multi Else-ifs \u0026 else\u003c/s\u003e\\\n10.\u003cs\u003eIf \u0026 multi Else-ifs\u003c/s\u003e\\\n11.More requirements for If-block and Else If-block\\\n12.Convenient variables managing\\\n13.\u003cs\u003eTry \u0026 Catch \u0026 Finally\u003c/s\u003e\\\n14.\u003cs\u003eAbstract class\u003c/s\u003e\\\n...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeechael%2Fdynamicclassgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeechael%2Fdynamicclassgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeechael%2Fdynamicclassgenerator/lists"}