Conversion of type parameters when creating executable references
- Dominant language
- Java
- Stars
- 2k
- Forks
- 392
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 36
Description
### Describe the bug
Updating an older project from spoon 5.5.x to latest version. Getting exception I have issues understanding the problem with...
Stacktrace:
```
Exception in thread "main" spoon.SpoonException: CtExecutableReference cannot use CtTypeParameterReference. Use boundingType of CtTypeParameterReference instead.
at spoon.support.reflect.reference.CtExecutableReferenceImpl.checkMethodParameterTypeRef(CtExecutableReferenceImpl.java:184)
at spoon.support.reflect.reference.CtExecutableReferenceImpl.addParameter(CtExecutableReferenceImpl.java:176)
at spoon.support.reflect.reference.CtExecutableReferenceImpl.setParameters(CtExecutableReferenceImpl.java:167)
at spoon.reflect.factory.CodeFactory.createConstructorCall(CodeFactory.java:192)
at spoon.reflect.factory.FactoryImpl.createConstructorCall(FactoryImpl.java:479)
at org.crumbleworks.forge.spoon_openglparser.LwjglOpenGLAPIProcessor.createCustomPointerBufferAndWrapper(LwjglOpenGLAPIProcessor.java:1312)
at org.crumbleworks.forge.spoon_openglparser.LwjglOpenGLAPIProcessor.process(LwjglOpenGLAPIProcessor.java:772)
at spoon.support.QueueProcessingManager.process(QueueProcessingManager.java:115)
at spoon.support.QueueProcessingManager.process(QueueProcessingManager.java:132)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.process(JDTBasedSpoonCompiler.java:194)
at spoon.Launcher.process(Launcher.java:791)
at org.crumbleworks.forge.spoon_openglparser.LwjglOpenGLAPIProcessor.main(LwjglOpenGLAPIProcessor.java:1478)
```
Code:
```
CtClass lwjglPB = getFactory().Class().get(PointerBuffer.class);
List> pbMethods = new ArrayList<>();
for(CtMethod method : lwjglPB.getAllMethods()) {
//some code filtering out methods we want/don't want
pbMethods.add(method);
}
}
//populate interface & wrapper
for(CtMethod ctMethod : pbMethods) {
CtMethod intfMethod = (CtMethod)ctMethod.clone();
//creating a wrapper method and doing some stuff for the wrapper
.
.
.
//add to interface
cwAPIPointerBuffer.addMethod(intfMethod);
//add to wrapper
CtMethod wrapMethod = (CtMethod)intfMethod.clone();
wrapMethod.setComments(null);
wrapMethod.addAnnotation(getFactory().Code().createAnnotation(getFactory().Annotation().createReference(Override.class)));
List> arguments = new LinkedList>();
for(CtParameter param : ctMethod.getParameters()) {
.
.
.
@SuppressWarnings("unchecked")
CtInvocation methodCall = (CtInvocation)getFactory().Code().createInvocation(
getFactory().createVariableRead(internalPointerBuffer.getReference(), false),
ctMethod.getReference(),
arguments);
//some more logic happening here, but the following is the only part that interacts with the methodCall object
//AND is the part that throws, the line that throws is marked with '->'
wrapMethod.setBody(getFactory().Core().createReturn().setReturnedExpression(
getFactory().createConstructorCall(
cwEnginePointerBufferWrapper.getReference(),
-> methodCall)
));
cwEnginePointerBufferWrapper.addMethod(wrapMethod);
}
```
I cannot provide the full sourcecode as of this moment, as there's a bunch of proprietory stuff in there. I am trying to narrow it down to a self-contained executable sample
### Source code you are trying to analyze/transform
_No response_
### Source code for your Spoon processing
_No response_
### Actual output
_No response_
### Expected output
_No response_
### Spoon Version
10.1.1
### JVM Version
18
### What operating system are you using?
Windows 11
Contributor guide
Assessment
This issue has not been assessed yet.