holgerfriedrich commented on code in PR #2870:
URL: https://github.com/apache/karaf/pull/2870#discussion_r3991555914
##########
services/interceptor/impl/src/main/java/org/apache/karaf/service/interceptor/impl/runtime/proxy/AsmProxyFactory.java:
##########
@@ -114,19 +114,31 @@ private boolean hasSameSignature(Method a, Method b) {
private void createConstructor(final ClassWriter cw, final String
proxyClassFileName, final Class<?> classToProxy,
final String classFileName) {
- Constructor superDefaultCt;
- String parentClassFileName = classFileName;
- String descriptor = "()V";
-
- try {
- if (classToProxy.isInterface()) {
- parentClassFileName = Type.getInternalName(Object.class);
- superDefaultCt = Object.class.getConstructor(null);
- descriptor = Type.getConstructorDescriptor(superDefaultCt);
+ // the proxy extends the proxied class, or Object when proxying an
interface; either way
+ // the super constructor it invokes is the no-arg one
+ final String parentClassFileName;
+ if (classToProxy.isInterface()) {
+ parentClassFileName = Type.getInternalName(Object.class);
+ } else {
+ parentClassFileName = classFileName;
+ // without these checks the generated INVOKESPECIAL would only
fail once the proxy is
+ // instantiated. The proxy is defined by its own class loader, so
it lands in a different
+ // runtime package than the proxied class: only a public or
protected constructor is
+ // reachable from it, a package-private one is not.
+ final Constructor<?> superCt;
+ try {
+ superCt = classToProxy.getDeclaredConstructor();
Review Comment:
let's catch `LinkageError`, this is what fails with the new tests.
Unfortunately it is not a declared exception of those functions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]