Re:
Remi Forax <[email protected]> Thu, 31 Aug 2017 12:00:30 +0000
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Yes, the ModuleNameClass is an internal name like the class name or the superclass name. Module names are the exception because they are plain names (with dot) and not internal names (with slash). Rémi On August 30, 2017 9:15:12 PM GMT+02:00, Plamen Totev <[email protected]> wrote: >Hi, > >I found the issue. Appears that '.'(dot) is illegal character for the >`ModuleMainClass` attribute. Its value should be set to >`org/foo/bar/Main` instead of `org.foo.bar.Main`. > >Regards, >Plamen Totev > >On Sun, Aug 27, 2017 at 6:31 PM, Remi Forax <[email protected]> wrote: >> Hi Robert, >> ModuleVisitor has a method visitEnd() that is called after having >seen all values, >> >> so a code like this should work. >> new ModuleVisitor(ASM6, parent) { >> private String mainClass = moduleMainClass; // default main >class >> >> public void visitMainClass(String mainClass) { >> this.mainClass = mainClass; // extracted main >class >> } >> >> public void visitEnd() { >> super.visitMainClass(mainClass); // set the main class >> } >> }; >> >> cheers, >> Rémi >> >> ----- Mail original ----- >>> De: "Robert Scholte" <[email protected]> >>> À: "asm" <[email protected]> >>> Envoyé: Samedi 26 Août 2017 18:53:56 >>> Objet: [asm] >> >>> Hi, >>> >>> I'm trying to add some extra information to the module-info.class >like done by >>> the jar executable of the jdk. In my case plexus-archiver is >responsible for >>> creating the jar. >>> >>> With the following code I get the following error: CONSTANT_Class at >entry 9 >>> has illegal character: '.' >>> >>> How should I change the following code? >>> >>> final String moduleVersion = "1.0.0" >>> >>> final String moduleMainClass = "org.foo.bar.Main"; >>> >>> ClassReader reader = new ClassReader( is ); >>> >>> ClassWriter writer = new >>> ClassWriter( ClassWriter.COMPUTE_FRAMES ); >>> >>> ClassVisitor classVisitor = new ClassVisitor( >Opcodes.ASM6, >>> writer ) >>> { >>> @Override >>> public ModuleVisitor visitModule( String name, >int access, >>> String __ ) >>> { >>> ModuleVisitor parent = super.visitModule( >name, >>> access, moduleVersion ); >>> >>> ModuleVisitor visitor = new >>> ModuleVisitor( Opcodes.ASM6, parent ) >>> { >>> boolean visitMainClassCalled; >>> >>> @Override >>> public void visitMainClass( String __ ) >>> { >>> if ( !visitMainClassCalled ) >>> { >>> super.visitMainClass( >moduleMainClass ); >>> visitMainClassCalled = true; >>> } >>> } >>> }; >>> visitor.visitMainClass( moduleMainClass ); >>> >>> return visitor; >>> } >>> }; >>> >>> reader.accept( classVisitor, Opcodes.ASM6 ); >>> >>> return new ByteArrayInputStream( writer.toByteArray() >); >>> >>> >>> -- >>> You receive this message as a subscriber of the [email protected] mailing >list. >>> To unsubscribe: mailto:[email protected] >>> For general help: mailto:[email protected]?subject=help >>> OW2 mailing lists service home page: http://www.ow2.org/wws >> >> >> -- >> You receive this message as a subscriber of the [email protected] mailing >list. >> To unsubscribe: mailto:[email protected] >> For general help: mailto:[email protected]?subject=help >> OW2 mailing lists service home page: http://www.ow2.org/wws >> -- Sent from my Android device with K-9 Mail. Please excuse my brevity. -- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws