Re:
Plamen Totev <[email protected]> Wed, 30 Aug 2017 22:15:12 +0300
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CALaTeCrqAt=4kBWAmU7aA5=JuH=kZJ7ZinLagWnyX7Y6UZYGDQ@mail.gmail.com> |
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 > -- 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