Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1027594 // Add new class from ByteBuddy to module's class loader Spike [WORKS, astonishingly]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 3273K of libraries. Click here for Pure Java version (17365L/122K).

!7

lib 1400352 // ByteBuddy

import net.bytebuddy.*;
import net.bytebuddy.dynamic.*;

module TestByteBuddy > DynPrintLog {
  start-thread {
    S className = "main$NewClass1";
    DynamicType.Unloaded maker = new ByteBuddy()
      .subclass(Concept)
      .name(className)
      .make();
    byte[] classData = cast _get binaryRepresentation(maker);
    
    //ClassLoader cl = module().getClass().getClassLoader();
    File jar = programFile("dynamic.jar");
    createZipFileWithSingleBinaryFile(jar, className + ".class", classData);
    addLibraryToCurrentProgram(jar);
    Class<? extends Concept> c = classForName(className);
    print(c);
    Concept cc = nu(c);
    print("Got concept: " + cc);
  }
}

Author comment

Began life as a copy of #1027593

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027594
Snippet name: Add new class from ByteBuddy to module's class loader Spike [WORKS, astonishingly]
Eternal ID of this version: #1027594/8
Text MD5: eb3b0cc24b525ec4ddc3b688a2fbcf1d
Transpilation MD5: e83aa65d3f468e9c845e5fafa5e996f3
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-25 14:23:51
Source code size: 733 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 205 / 366
Version history: 7 change(s)
Referenced in: #1027598 - byteBuddy_newSubClass_bytes