[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-700987-105":59,"doc-detail-700987-en":130,"doc-similar-700987":164},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","the-definitive-guide-to-java-agents-agent-fundamentals-code-instrumentation-class-loading-miscellaneous","The definitive guide to Java agents - agent fundamentals - code instrumentation - class loading - miscellaneous","","The definitive guide to Java agents covers agent fundamentals, code instrumentation, and class loading. It explains what Java agents are and how to configure agent entry points using Premain-Class for static agents and Agent-Class for agentmain-driven execution. The guide provides runnable examples for running static, attaching a dynamic agent via VirtualMachine, transforming and retransformation with Instrumentation, and notes limitations. It also covers running native agents through JVMTI event hooks.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/the-definitive-guide-to-java-agents-agent-fundamentals-code-instrumentation-class-loading-miscellaneous/700987/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/the-definitive-guide-to-java-agents-agent-fundamentals-code-instrumentation-class-loading-miscellaneous/700987.png","ImageObject",300,407,{"name":92,"@type":93},"DoDO","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-24","2026-11-12",true,{"@type":102,"interactionType":103,"userInteractionCount":24},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What is the difference between static and dynamic Java agents?","Question",{"text":112,"@type":113},"A static agent uses Premain-Class and a premain() entry point. A dynamic agent uses Agent-Class with an agentmain() entry point and can be attached at runtime.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"How do you transform classes with Instrumentation in a Java agent?",{"text":117,"@type":113},"The agent registers a ClassFile transformer via inst.addTransformer(...) and returns transformed bytecode for classes that match the shouldTransform condition.",{"name":119,"@type":110,"acceptedAnswer":120},"What limitations apply to retransformation?",{"text":121,"@type":113},"Retransformation behavior is constrained by what classes and definitions can be reprocessed safely. The document highlights retransformation limitations with examples and notes future possibilities but not an immediate goal.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},700987,1794522632,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":24,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":139,"language":140,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":67,"update_tm":129,"read_time":144,"preview_page_count":24,"preview_urls":145},962093270745,"https://ap-avatar.wpscdn.com/davatar_9964176cb1d06d4a9deccf72a44ae3dc","The definitive guide to Java agents  \nagent fundamentals  \ncode instrumentation  \nclass loading  \nmiscellaneous  \nWhat are Java agents?  \nPremain-Class: agent.PreEntry  \n| main thread |  |  |  |\n| --- | --- | --- | --- |\n|  | \u003Cbr>premain() | \u003Cbr>premain() | \u003Cbr>\u003Cbr>main()\u003Cbr>|\n|  |  |  |  |\n\n\n| attach\u003Cbr>thread | \u003Cbr>agentmain() agentmain() |\n| --- | --- |\n\nAgent-Class: agent.AgentEntry  \nRunning a static Java agent  \njava -cp: . -javaagent:/home/user/myagent.jar=MyAgent main.AppEntry  \nclass PreEntry {  \npublic static void premain (String arg) { System .out .println ( \"Hello from \" + arg);  \n}  \n}  \nRunning a dynamic Java agent  \njava -cp: . main.AppEntry  \nclass AgentEntry {  \npublic static void agentmain (String arg) { System .out .println ( \"Hello from \" + arg);  \n}  \n}  \nVirtualMachine vm = VirtualMachine .attach (pid);  \ntry {  \nvm .loadAgent (\"/home/user/myagent.jar\" , \"MyAgent \" );} finally {  \nvm .detach();}  \nIf owned by same user  \nTransforming a class  \njava -cp: . -javaagent:/home/user/myagent.jar=MyAgent main.AppEntry  \nclass PreEntry {  \npublic static void premain (String arg , Instrumentation inst) { inst .addTransformer (  \n( classLoader , className , classIfLoaded , protectionDomain , classFile) -> { if ( shouldTransform ( className )) {  \nreturn transform (classFile);  \n} else {  \nreturn null ;  \n}  \n});  \n}  \n}  \nRetransforming a class  \njava -cp: . main.AppEntry  \nclass AgentEntry {  \npublic static void agentmain (String arg , Instrumentation inst) { inst .addTransformer (  \n( classLoader , className , classIfLoaded , protectionDomain , classFile) -> {  \nif ( shouldTransform ( classIfLoaded )) { return transform (classFile);  \n} else {  \nreturn null ;  \n}  \n}, true);  \ninst .retransformClasses ( getClassesToRe transform ());  \n}}  \nRetransforming a class: limitations  \nclass Sample { String m () {  \nreturn () \";;  \n}  \n} ~~ private ~~~~t~~~~ ~~~~n ~~~~ m2 () ~~ { return \"bar \" ;  \n}  \n}  \nPossible future extension: JEP 159 or Dynamic code evolution VM But currently this does not seem to be a goal.  \nRunning a native agent  \n[java](java -agentlib:/home/user/myagent.so=MyAgent main.AppEntry)[ -](java -agentlib:/home/user/myagent.so=MyAgent main.AppEntry)[agentlib](java -agentlib:/home/user/myagent.so=MyAgent main.AppEntry)[:/](java -agentlib:/home/user/myagent.so=MyAgent main.AppEntry)[home](java -agentlib:/home/user/myagent.so=MyAgent main.AppEntry)[/](java -agentlib:/home/user/myagent.so=MyAgent main.AppEntry)[user](java -agentlib:/home/user/myagent.so=MyAgent main.AppEntry)[/](java -agentlib:/home/user/myagent.so=MyAgent main.AppEntry)[myagent.so](java -agentlib:/home/user/myagent.so=MyAgent main.AppEntry)[=](java -agentlib:/home/user/myagent.so=MyAgent main.AppEntry)[MyAgent main.AppEntry](java -agentlib:/home/user/myagent.so=MyAgent main.AppEntry)  \n[JNIEXPORT jint JNICALL Agent_OnLoad](JNIEXPORT jint JNICALL Agent_OnLoad) (  \nJavaVM *jvm , char *options , void *reserved) { jvmtiEnv *jvmti; jint res ; jvmtiError error ;  \njvmtiCapabilities capabilities ; jvmtiEventCallbacks callbacks ;  \nres = (*vm)->GetEnv (vm , (void **)&jvmti , JVMTI_VERSION_ 1);  \n(void) memset (&capabilities , 0 , sizeof (jvmtiCapabilities)); capabilities .can_retransform_classes = 1 ;  \nerror = jvmti->AddCapabilities (&capabilities);  \ncallbacks .ClassFileLoadHook = &myClassFileLoadHook;  \nerror = (*jvmti)->SetEventCallbacks (jvmti , &callbacks , (jint) sizeof (callbacks));  \nreturn JNI_OK ;}  \nHow can classes be manipulated at runtime?  \n[Foo.java](Foo.java)  \nclass Foo  \nConstant pool:  \n\\#1 = String \\#4  \n\\#2 = Class \\#6  \n\\#3 = Utf8 Code  \n\\#4 = Utf8 bar  \n\\#5 = Utf8 () Ljava/lang/String;  \n\\#6 = Utf8 Foo  \n\\#7 = Utf8 java/lang/Object java .lang .String bar();  \ndescriptor: () Ljava/lang/String; Code:  \n0: ldc \\#2  \n2: areturn  \nFoo.class (javap)  \nca fe ba be 00 00 00 34 00 10 0a 00 04 00 0d 08 00 09 07 00 0e 07 00 0f 01 00 06 3c 69 6e 69 74 3e 01 00 03 28 29 56 01 00 04 43 6f 64 65 01 00 0f 4c 69 6e 65 4e 75 6d 62 65 72 54 6","cbCaiqbbhdV1a7cY","https://ap.wps.com/l/cbCaiqbbhdV1a7cY","pdf",437969,41,"English","# What are Java agents?\n## Premain-Class and premain()\n## Agent-Class and agentmain()\n## Running a static Java agent\n## Running a dynamic Java agent\n## Transforming a class\n## Retransforming a class and limitations\n## Running a native agent\n## Manipulating classes at runtime","[{\"question\":\"What is the difference between static and dynamic Java agents?\",\"answer\":\"A static agent uses Premain-Class and a premain() entry point. A dynamic agent uses Agent-Class with an agentmain() entry point and can be attached at runtime.\"},{\"question\":\"How do you transform classes with Instrumentation in a Java agent?\",\"answer\":\"The agent registers a ClassFile transformer via inst.addTransformer(...) and returns transformed bytecode for classes that match the shouldTransform condition.\"},{\"question\":\"What limitations apply to retransformation?\",\"answer\":\"Retransformation behavior is constrained by what classes and definitions can be reprocessed safely. The document highlights retransformation limitations with examples and notes future possibilities but not an immediate goal.\"}]","The definitive guide to Java agents - agent fundamentals - code instrumentation - class loading - miscellaneous | PDF",103,[146,150,153,157,160],{"page_no":8,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/6917913e8ba22184aa837adb7bf50785.webp",983,552,{"page_no":14,"url":151,"width":152,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/5eefaa24b3c0eac8b742d754175d97f3.webp",982,{"page_no":81,"url":154,"width":155,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/6eb97c3d544f35d04de7484bff4f95f6.webp",981,551,{"page_no":19,"url":158,"width":159,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/143906ab514768b04e5ff9edf05a1167.webp",980,{"page_no":24,"url":161,"width":162,"height":163},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/1ba3beaef79642f297bd52440f3909d6.webp",979,550,{"list":165,"token":66},[166,173,179,186,192,198,204,211,218,224],{"doc_id":167,"doc_title":168,"file_type":137,"home_preview_img_url":169,"slug":170,"view_count":171,"category_name":30,"create_tm":172},82767,"SkillFab: An Agent-Native Skill Production Platform","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229808908411/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796125499&Signature=euv2ZoLIAuSJXVKoxFFKj2R2M%2BE%3D","skillfab-an-agent-native-skill-production-platform",25,1784182812,{"doc_id":174,"doc_title":175,"file_type":137,"home_preview_img_url":176,"slug":177,"view_count":19,"category_name":30,"create_tm":178},733000,"Build AI Multi-Agent with Claude Code - Course Outline","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031415117/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796125499&Signature=RBp0aDI3EHoWIt2%2FWHJhdrdMvpo%3D","build-ai-multi-agent-with-claude-code-course-outline",1795383252,{"doc_id":180,"doc_title":181,"file_type":137,"home_preview_img_url":182,"slug":183,"view_count":184,"category_name":30,"create_tm":185},265714,"Aztec Enhanced Administration Guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229898465850/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796125499&Signature=u5hqbg0GmNE9T5u5%2FlseBLX%2BbgA%3D","aztec-enhanced-administration-guide",16,1789399938,{"doc_id":187,"doc_title":188,"file_type":137,"home_preview_img_url":189,"slug":190,"view_count":34,"category_name":30,"create_tm":191},655582,"The UML Class Diagram - Class Diagram Basics - 2","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229974775251/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796125499&Signature=6sEEjIdyBi18jr86ryeiOBw4IqY%3D","the-uml-class-diagram-class-diagram-basics-2",1792962726,{"doc_id":193,"doc_title":194,"file_type":137,"home_preview_img_url":195,"slug":196,"view_count":52,"category_name":30,"create_tm":197},733005,"The Claude Code Playbook - Edition 2026","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031782331/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796125499&Signature=Y1ua%2BniBjBe3dZ%2B1AGOvXbhsyEo%3D","the-claude-code-playbook-edition-2026",1795383306,{"doc_id":199,"doc_title":200,"file_type":137,"home_preview_img_url":201,"slug":202,"view_count":52,"category_name":30,"create_tm":203},511564,"Instant Campaign Builder - A Dungeon Master Tool Guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229935739444/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796125499&Signature=wgwTGgxziNgt3X49TDyLBBbnjQw%3D","instant-campaign-builder-a-dungeon-master-tool-guide",1791254421,{"doc_id":205,"doc_title":206,"file_type":137,"home_preview_img_url":207,"slug":208,"view_count":209,"category_name":30,"create_tm":210},347826,"Advanced java - Part 1 - How to create and destroy objects","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229911558162/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796125499&Signature=vaFoxLPQT7YXWtm%2FejB8Bpy3z1A%3D","advanced-java-part-1-how-to-create-and-destroy-objects",14,1790069260,{"doc_id":212,"doc_title":213,"file_type":137,"home_preview_img_url":214,"slug":215,"view_count":216,"category_name":30,"create_tm":217},682280,"Startup technical guide - AI agents - How to build, use, and scale","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229998475801/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796125499&Signature=par6CDCwRrf8lUrIT2smf5D1nR4%3D","startup-technical-guide-ai-agents-how-to-build-use-and-scale",15,1793964970,{"doc_id":219,"doc_title":220,"file_type":137,"home_preview_img_url":221,"slug":222,"view_count":81,"category_name":30,"create_tm":223},700986,"ASM 4.0 - Java bytecode engineering library - Version 2.0 September 2011","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230011575673/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796125499&Signature=CbePdNrB%2BnGKoY%2B6Qrq4i9od2LE%3D","asm-40-java-bytecode-engineering-library-version-20-september-2011",1794522631,{"doc_id":225,"doc_title":226,"file_type":137,"home_preview_img_url":227,"slug":228,"view_count":229,"category_name":30,"create_tm":230},114467,"Practical Multi-Agent AI Systems - Murali Kashaboina","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229830543128/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796125499&Signature=an5lPpGt%2BfJImDdXk%2F23jeryod0%3D","practical-multi-agent-ai-systems-murali-kashaboina",164,1785400162]