Code Monkey home page Code Monkey logo

jboss-classfilewriter's People

Contributors

dependabot[bot] avatar grgrzybek avatar jharting avatar manovotn avatar mkouba avatar ropalka avatar stuartwdouglas avatar tadamski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jboss-classfilewriter's Issues

May I get source code or only modified class?

May I get source code on classwriter?
For example of HttpRequestParser(Undertow) ..its generated to HttpRequestParser$$generated.class(using org.jboss.classfilewriter)
I was researching how Undertow working /Get dependences/Up on IDE(JDeveloper) ,
wanted trace (debug )way request /response, but discovered what way go out in HttpRequestParser$$generayed.class.
This one is a generated tricky, complicate process, of «parser-generator»(io.undertow.annotationprocessor use
org.jboss.classfilewriter
https://github.com/undertow-io/undertow/tree/master/parser-generator/src/main/java/io/undertow/annotationprocessor
)
and I did not found
HttpRequestParser$$generayed.java in annotation-source target.
I was writed
com.sun.tools.javac.Main.main (new String[] {"-proc:only", "-processor", "io.undertow.annotationprocessor.HttpParserAnnotationProcessor", "HttpRequestParser.java"});

Append code to HttpParserAnnotationProcessor(process)
JavaFileObject jfo = filer.createSourceFile(classElement.getQualifiedName() + "Info");

But I get only class file and empty source file;
How I can get source code for annotation? May I modyfy code to get source?(or jboss-classfilefriter working only class files?)

(On undertow within portal does not exist issue
Writed on https://issues.redhat.com/projects/UNDERTOW
No answer.
)

CFW is using Unsafe to define classes which fails on Java 11

Java 11 has deleted the Unsafe.defineClass method. Instead of using this method, we could use an alternative strategy:

  • Reflectively access ClassLoader.defineClass (maybe using Unsafe to toggle the accessibility flag)
  • When running with a JBoss Modules class loader (1.9 or later), use org.jboss.modules.ClassDefiner to define generated classes
  • Some other option?

OSGify jboss-classfilewriter

Weld depends on jboss-classfilewriter. Since Weld is also used in OSGi enrivonment we have to embed jboss-classfilewriter in Weld's OSGi bundle. It would be cleaner if jboss-classfilewriter itself could be used as an OSGi bundle.

JDK12 b14 java.lang.NoSuchFieldException: override

Caused By: java.lang.NoSuchFieldException: override
at java.base/java.lang.Class.getDeclaredField(Class.java:2412)
at org.jboss.classfilewriter.ClassFile$1.run(ClassFile.java:392)
at org.jboss.classfilewriter.ClassFile$1.run(ClassFile.java:385)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.jboss.classfilewriter.ClassFile.(ClassFile.java:385)
Truncated. see log file for complete stacktrace

Fix StackMapTable attribute support

Currently it's always marked as invalid and apparently ignored when CodeAttribute is written.

This is likely the cause (or one of the causes) of WELD-2093.

Reproducer - a simple example (created during weld knowledge share):
https://github.com/mkouba/bytecode-basics/blob/master/src/main/java/learn/bytecode/Main.java#L93-L101

If you run the Main, you'll get the "java.lang.VerifyError: Expecting a stackmap frame at branch target". I'm not sure it's caused solely by the absence of StackMapTable. But the truth is it might be problem with future versions of JVM (even now it seems the JVMs are not required to fallback to verification by type inference for 50.0).

Unified construct for forward/reverse branching

Right now you have to use different constructs for forward versus backward branches. It's easy enough to write a marker class which automatically backfills branches, but putting this in the main API would be a nice feature. Also something that is not really possible is to combine multiple such markers - to do so would require BranchEnds to be filled by a CodeLocation (right now they can only be added as a mark into the CodeAttribute's current position).

support generic field

generic field support is important imho, w/o it, we need to do lots of extra work to use the generated class
for example, i'm trying to use classwriter to generate class for hibernate testing, and the jpa collection annotation requires generic type to dertimine the underlying collection element type, or i have to set targetClass property for ElementCollection annotations.

thanks

Weld fails to start on Java 17 (since build 21)

Since build OpenJDK Runtime Environment (build 17-ea+21-1866) weld fails to start due to issue in EnumAnnotationValue.

This issue was fixed in PR #15, though it was never merged.

How to reproduce (with Weld):

  • create a bean with an annotation that uses an enum value
  • start Weld

How to reproduce in general:

  • create a ClassFile from a class with an enum annotation value
  • load the class
  • call getAnnotations() on the loaded class

Stack trace (from Weld):

Exception in thread "main" java.lang.reflect.GenericSignatureFormatError: Signature Parse error: Expected Field Type Signature
	Remaining input: org.eclipse.microprofile.openapi.annotations.enums.SchemaType
	at java.base/sun.reflect.generics.parser.SignatureParser.error(SignatureParser.java:124)
	at java.base/sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:291)
	at java.base/sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:277)
	at java.base/sun.reflect.generics.parser.SignatureParser.parseTypeSignature(SignatureParser.java:469)
	at java.base/sun.reflect.generics.parser.SignatureParser.parseTypeSig(SignatureParser.java:188)
	at java.base/sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:430)
	at java.base/sun.reflect.annotation.AnnotationParser.parseEnumValue(AnnotationParser.java:468)
	at java.base/sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:343)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:282)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:227)
	at java.base/sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:348)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:282)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:227)
	at java.base/sun.reflect.annotation.AnnotationParser.lambda$parseAnnotationArray$2(AnnotationParser.java:726)
	at java.base/sun.reflect.annotation.AnnotationParser.parseArrayElements(AnnotationParser.java:737)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotationArray(AnnotationParser.java:725)
	at java.base/sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:528)
	at java.base/sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:351)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:282)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:121)
	at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:73)
	at java.base/java.lang.reflect.Executable.declaredAnnotations(Executable.java:624)
	at java.base/java.lang.reflect.Executable.declaredAnnotations(Executable.java:622)
	at java.base/java.lang.reflect.Executable.getDeclaredAnnotations(Executable.java:610)
	at java.base/java.lang.reflect.Method.getDeclaredAnnotations(Method.java:747)
	at java.base/java.lang.reflect.AccessibleObject.getAnnotations(AccessibleObject.java:566)
	at org.jboss.weld.resources.HotspotReflectionCache.internalGetAnnotations(HotspotReflectionCache.java:58)
	at org.jboss.weld.resources.DefaultReflectionCache.lambda$new$0(DefaultReflectionCache.java:40)
	at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.lambda$new$0(ReentrantMapBackedComputingCache.java:55)
	at org.jboss.weld.util.LazyValueHolder$1.computeValue(LazyValueHolder.java:32)
	at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:46)
	at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getValue(ReentrantMapBackedComputingCache.java:72)
	at org.jboss.weld.resources.DefaultReflectionCache.getAnnotations(DefaultReflectionCache.java:75)
	at org.jboss.weld.annotated.slim.backed.BackedAnnotated.getAnnotations(BackedAnnotated.java:36)
	at org.jboss.weld.annotated.enhanced.jlr.EnhancedAnnotatedMethodImpl.of(EnhancedAnnotatedMethodImpl.java:61)
	at org.jboss.weld.annotated.enhanced.jlr.EnhancedAnnotatedTypeImpl.<init>(EnhancedAnnotatedTypeImpl.java:224)
	at org.jboss.weld.annotated.enhanced.jlr.EnhancedAnnotatedTypeImpl.of(EnhancedAnnotatedTypeImpl.java:134)
	at org.jboss.weld.resources.ClassTransformer$TransformSlimAnnotatedTypeToEnhancedAnnotatedType.apply(ClassTransformer.java:93)
	at org.jboss.weld.resources.ClassTransformer$TransformSlimAnnotatedTypeToEnhancedAnnotatedType.apply(ClassTransformer.java:90)
	at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.lambda$new$0(ReentrantMapBackedComputingCache.java:55)
	at org.jboss.weld.util.LazyValueHolder$1.computeValue(LazyValueHolder.java:32)
	at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:46)
	at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getValue(ReentrantMapBackedComputingCache.java:72)
	at org.jboss.weld.resources.ClassTransformer.getEnhancedAnnotatedType(ClassTransformer.java:251)
	at org.jboss.weld.resources.ClassTransformer.getEnhancedAnnotatedType(ClassTransformer.java:232)
	at org.jboss.weld.injection.producer.SubclassedComponentInstantiator.initEnhancedSubclass(SubclassedComponentInstantiator.java:86)
	at org.jboss.weld.injection.producer.SubclassedComponentInstantiator.<init>(SubclassedComponentInstantiator.java:79)
	at org.jboss.weld.injection.producer.SubclassedComponentInstantiator.forInterceptedDecoratedBean(SubclassedComponentInstantiator.java:63)
	at org.jboss.weld.injection.producer.BeanInjectionTarget.initializeAfterBeanDiscovery(BeanInjectionTarget.java:121)
	at org.jboss.weld.injection.producer.InjectionTargetInitializationContext.initialize(InjectionTargetInitializationContext.java:42)
	at org.jboss.weld.injection.producer.InjectionTargetService.initialize(InjectionTargetService.java:63)
	at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:481)
	at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:86)

Wrong OSGi headers generated with old maven-bundle-plugin

jboss-classfilewriter 1.3.0.Final available at Maven Central has this OSGi META-INF/MANIFEST.MF header:

Require-Capability: osgi.ee;filter:="(osgi.ee=UNKNOWN)"

maven-bundle-plugin 3.3.0 is quite old and didn't know much about JDK11.

It's enough to change the version of the plugin.

StringValuedAnnotation.java missing

Hi Stuart, I think you forgot to check-in StringValuedAnnotation.java file. Tests for 1.0.1.Final fail because of this:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project jboss-classfilewriter: Compilation failure: Compilation failure:
[ERROR] bootstrap class path not set in conjunction with -source 1.6
[ERROR] /home/goldmann/fedora/jboss-classfilewriter/BUILD/jboss-classfilewriter-1.0.1.Final/src/test/java/org/jboss/classfilewriter/test/annotation/MethodAnnotationClass.java:[56,30] error: cannot find symbol
[ERROR] class MethodAnnotationClass
[ERROR] /home/goldmann/fedora/jboss-classfilewriter/BUILD/jboss-classfilewriter-1.0.1.Final/src/test/java/org/jboss/classfilewriter/test/annotation/MethodAnnotationClass.java:[55,5] error: cannot find symbol
[ERROR] class MethodAnnotationClass
[ERROR] /home/goldmann/fedora/jboss-classfilewriter/BUILD/jboss-classfilewriter-1.0.1.Final/src/test/java/org/jboss/classfilewriter/test/annotation/MethodAnnotationTest.java:[44,40] error: cannot find symbol
[ERROR] class MethodAnnotationTest
[ERROR] /home/goldmann/fedora/jboss-classfilewriter/BUILD/jboss-classfilewriter-1.0.1.Final/src/test/java/org/jboss/classfilewriter/test/annotation/MethodAnnotationTest.java:[46,40] error: cannot find symbol
[ERROR] -> [Help 1]

JDK9 Reference To Internal APIs

When running with Jigsaw b162 or later with --permit-illegal-access, the following warnings are generated.
This is due to use of setAccessible to break into JDK classes.

WARNING: Illegal access by org.jboss.classfilewriter.ClassFile$1 (file:/modules/org.jboss.classfilewriter.jboss-classfilewriter.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Illegal access by org.jboss.classfilewriter.ClassFile$1 (file:/modules/org.jboss.classfilewriter.jboss-classfilewriter.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)

DuplicateMemberException

How to fix this issue?
DuplicateMemberException Method already exists

Stacktrace:
org.jboss.classfilewriter.ClassFile.addMethod(ClassFile.java:180)
org.jboss.classfilewriter.ClassFile.addMethod(ClassFile.java:195)
org.jboss.weld.bean.proxy.ProxyFactory.addMethodsFromClass(ProxyFactory.java:611)
org.jboss.weld.bean.proxy.ProxyFactory.addMethods(ProxyFactory.java:564)
org.jboss.weld.bean.proxy.ClientProxyFactory.addMethods(ClientProxyFactory.java:113)
org.jboss.weld.bean.proxy.ProxyFactory.createProxyClass(ProxyFactory.java:457)
org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:370)
org.jboss.weld.bean.proxy.ProxyFactory.run(ProxyFactory.java:331)
org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:323)
org.jboss.weld.bean.proxy.ClientProxyFactory.create(ClientProxyFactory.java:83)
org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:205)
org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:195)
org.jboss.weld.bean.proxy.ClientProxyProvider.access$
org.jboss.weld.bean.proxy.ClientProxyProvider$CreateClientProxy.apply(ClientProxyProvider.java:52)
org.jboss.weld.bean.proxy.ClientProxyProvider$CreateClientProxy.apply(ClientProxyProvider.java:48)
org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.lambda$
org.jboss.weld.util.cache.ReentrantMapBackedComputingCache$$Lambda$.get
org.jboss.weld.util.LazyValueHolder$1.computeValue(LazyValueHolder.java:32)
org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:46)
org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getValue(ReentrantMapBackedComputingCache.java:72)
org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getCastValue(ReentrantMapBackedComputingCache.java:78)
org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:229)
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:688)
org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:794)
org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)
org.jboss.weld.util.Beans.injectBoundFields(Beans.java:336)
org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:347)
org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:69)
com.ibm.ws.cdi.impl.weld.injection.WebSphereInjectionServicesImpl$3.run(WebSphereInjectionServicesImpl.java:323)
com.ibm.ws.cdi.impl.weld.injection.WebSphereInjectionServicesImpl$3.run(WebSphereInjectionServicesImpl.java:320)
java.security.AccessController.doPrivileged(AccessController.java:678)
com.ibm.ws.cdi.impl.weld.injection.WebSphereInjectionServicesImpl.aroundInject(WebSphereInjectionServicesImpl.java:320)
org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46)
org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:71)
org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117)
org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:161)
org.jboss.weld.contexts.unbound.DependentContextImpl.get(DependentContextImpl.java:64)
org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:694)
org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:794)
org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.