polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject polygene-java git commit: Better error message for missing return types need to be public classes or interfaces
Date Fri, 09 Jun 2017 05:42:53 GMT
Repository: polygene-java
Updated Branches:
  refs/heads/develop 4f1527980 -> 49ead2fd8


Better error message for missing return types need to be public classes or interfaces

Signed-off-by: niclas <niclas@hedhman.org>

(cherry picked from commit 0f58a7d)
Signed-off-by: niclas <niclas@hedhman.org>


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/49ead2fd
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/49ead2fd
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/49ead2fd

Branch: refs/heads/develop
Commit: 49ead2fd82cd1ee4bd731c0ff7e140f23639a0b3
Parents: 4f15279
Author: niclas <niclas@hedhman.org>
Authored: Fri Jun 9 12:37:41 2017 +0800
Committer: niclas <niclas@hedhman.org>
Committed: Fri Jun 9 12:39:36 2017 +0800

----------------------------------------------------------------------
 .../runtime/composite/ConstructorModel.java        |  5 +++--
 .../composite/TypedModifierInvocationHandler.java  | 17 ++++++++++++++++-
 2 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/49ead2fd/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstructorModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstructorModel.java
b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstructorModel.java
index 427cff0..026a4e1 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstructorModel.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstructorModel.java
@@ -27,13 +27,14 @@ import java.util.stream.Stream;
 import org.apache.polygene.api.common.ConstructionException;
 import org.apache.polygene.api.composite.ConstructorDescriptor;
 import org.apache.polygene.api.composite.InvalidCompositeException;
-import org.apache.polygene.api.util.AccessibleObjects;
 import org.apache.polygene.api.util.HierarchicalVisitor;
 import org.apache.polygene.api.util.VisitableHierarchy;
 import org.apache.polygene.runtime.injection.DependencyModel;
 import org.apache.polygene.runtime.injection.InjectedParametersModel;
 import org.apache.polygene.runtime.injection.InjectionContext;
 
+import static org.apache.polygene.api.util.AccessibleObjects.accessible;
+
 /**
  * JAVADOC
  */
@@ -46,7 +47,7 @@ public final class ConstructorModel
 
     public ConstructorModel( Constructor<?> constructor, InjectedParametersModel parameters
)
     {
-        this.constructor = AccessibleObjects.accessible( constructor );
+        this.constructor = accessible( constructor );
         this.parameters = parameters;
     }
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/49ead2fd/core/runtime/src/main/java/org/apache/polygene/runtime/composite/TypedModifierInvocationHandler.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/TypedModifierInvocationHandler.java
b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/TypedModifierInvocationHandler.java
index 7d96abf..bf750e9 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/TypedModifierInvocationHandler.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/TypedModifierInvocationHandler.java
@@ -21,6 +21,7 @@ package org.apache.polygene.runtime.composite;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 
 /**
  * JAVADOC
@@ -38,7 +39,21 @@ public final class TypedModifierInvocationHandler
         }
         catch( InvocationTargetException e )
         {
-            throw cleanStackTrace( e.getTargetException(), proxy, method );
+            Throwable targetException = e.getTargetException();
+            if( targetException instanceof IllegalAccessError )
+            {
+                // We get here if any of the return types or parameters are not public. This
is probably due to
+                // the _Stub class ends up in a different classpace than the original mixin.
We intend to fix this in
+                // 3.1 or 3.2
+                if( !Modifier.isPublic( method.getReturnType().getModifiers() ) )
+                {
+                    String message = "Return types must be public: " + method.getReturnType().getName();
+                    IllegalAccessException illegalAccessException = new IllegalAccessException(
message );
+                    illegalAccessException.initCause( e.getTargetException() );
+                    throw cleanStackTrace( illegalAccessException, proxy, method );
+                }
+            }
+            throw cleanStackTrace( targetException, proxy, method );
         }
         catch( Throwable e )
         {


Mime
View raw message