Skip to main content
added 137 characters in body
Source Link
gudenau
  • 131
  • 5

Edit: Clarification:

I want to create a named module during runtime and put dynamically loaded classes into the created module.

I am attempting to build a framework that allows for code generation that is compatible with Java 9's module system. I require the ability to load some generated byte code into a "virtual" module.

From what I can tell after looking though the Java code there are no exported and public methods that allow me to do anything like this, but I am sure I am missing something.

For an example, let's say this class is generated for the module "handler".

package handler;
 
public class ModHandler{
    public static String fireEvent(){
        return "This is a string from the generated module!";
    }
}

How do I make the "handler" module and load the bytecode into it? How would you add exports and requires into the module? I do not want to write anything to the disk to implement this.

I am attempting to build a framework that allows for code generation that is compatible with Java 9's module system. I require the ability to load some generated byte code into a "virtual" module.

From what I can tell after looking though the Java code there are no exported and public methods that allow me to do anything like this, but I am sure I am missing something.

For an example, let's say this class is generated for the module "handler".

package handler;
 
public class ModHandler{
    public static String fireEvent(){
        return "This is a string from the generated module!";
    }
}

How do I make the "handler" module and load the bytecode into it? How would you add exports and requires into the module? I do not want to write anything to the disk to implement this.

Edit: Clarification:

I want to create a named module during runtime and put dynamically loaded classes into the created module.

I am attempting to build a framework that allows for code generation that is compatible with Java 9's module system. I require the ability to load some generated byte code into a "virtual" module.

From what I can tell after looking though the Java code there are no exported and public methods that allow me to do anything like this, but I am sure I am missing something.

For an example, let's say this class is generated for the module "handler".

package handler;
 
public class ModHandler{
    public static String fireEvent(){
        return "This is a string from the generated module!";
    }
}

How do I make the "handler" module and load the bytecode into it? How would you add exports and requires into the module? I do not want to write anything to the disk to implement this.

Source Link
gudenau
  • 131
  • 5

Runtime Java Module Generation for Game Plugins

I am attempting to build a framework that allows for code generation that is compatible with Java 9's module system. I require the ability to load some generated byte code into a "virtual" module.

From what I can tell after looking though the Java code there are no exported and public methods that allow me to do anything like this, but I am sure I am missing something.

For an example, let's say this class is generated for the module "handler".

package handler;
 
public class ModHandler{
    public static String fireEvent(){
        return "This is a string from the generated module!";
    }
}

How do I make the "handler" module and load the bytecode into it? How would you add exports and requires into the module? I do not want to write anything to the disk to implement this.