Author: sbratton
Date: Tue Feb 2 12:49:39 2016
New Revision: 1728108
URL: http://svn.apache.org/viewvc?rev=1728108&view=rev
Log:
[ARIES-1492] Exception creating a subclass proxy of class with package-private
access modifer.
Added:
aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassPackageAccessCtor.java
(with props)
Modified:
aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/gen/ProxySubclassAdapter.java
aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java
Modified:
aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/gen/ProxySubclassAdapter.java
URL:
http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/gen/ProxySubclassAdapter.java?rev=1728108&r1=1728107&r2=1728108&view=diff
==============================================================================
---
aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/gen/ProxySubclassAdapter.java
(original)
+++
aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/gen/ProxySubclassAdapter.java
Tue Feb 2 12:49:39 2016
@@ -146,17 +146,7 @@ public class ProxySubclassAdapter extend
// So what we do is build up the calling of the superclasses constructor
using nulls and default values. This means that the
// class bytes can be verified by the JVM, and then in the
ProxySubclassGenerator, we load the class without invoking the
// constructor.
- String constructorString = constructors[0].toGenericString();
- Method constructor = null;
- if (constructorString.indexOf(")") != -1) {
- //If constructor throws two or more exceptions, getMethod(String) will
report a StringIndexOutOfBounds exception,
- //so attempt to remove exceptions
- constructor = Method.getMethod(constructorString.substring(0,
constructorString.indexOf(")") + 1));
- } else {
- //As a backup, just pass in the generic string as before
- constructor = Method.getMethod(constructorString);
- }
-
+ Method constructor = Method.getMethod(constructors[0]);
Type[] argTypes = constructor.getArgumentTypes();
if (argTypes.length == 0) {
methodAdapter.invokeConstructor(Type.getType(superclassClass), new
Method("<init>", Type.VOID_TYPE, NO_ARGS));
Modified:
aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java
URL:
http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java?rev=1728108&r1=1728107&r2=1728108&view=diff
==============================================================================
---
aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java
(original)
+++
aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java
Tue Feb 2 12:49:39 2016
@@ -142,7 +142,7 @@ public class ProxySubclassGeneratorTest
assertEquals("Sets were not the same", expectedMethods, generatedMethods);
}
-
+
/**
* Test a method marked final
*/
@@ -180,7 +180,18 @@ public class ProxySubclassGeneratorTest
assertNotNull("The new instance was null", o);
}
-
+
+ /**
+ * Test a generating proxy class of class with package access constructor.
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testPackageAccessCtor() throws Exception {
+ Class<ProxyTestClassPackageAccessCtor> proxyClass =
+ (Class<ProxyTestClassPackageAccessCtor>)
ProxySubclassGenerator.getProxySubclass(ProxyTestClassPackageAccessCtor.class);
+ ProxyTestClassPackageAccessCtor proxy =
(ProxyTestClassPackageAccessCtor) getProxyInstance(proxyClass);
+ assertNotNull("The new instance was null", proxy);
+ }
// /**
// * Test object equality between real and proxy using a Collaborator
// */
Added:
aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassPackageAccessCtor.java
URL:
http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassPackageAccessCtor.java?rev=1728108&view=auto
==============================================================================
---
aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassPackageAccessCtor.java
(added)
+++
aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassPackageAccessCtor.java
Tue Feb 2 12:49:39 2016
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.proxy;
+
+public class ProxyTestClassPackageAccessCtor {
+
+ int[] arr;
+ String str;
+ boolean bool;
+
+ /* Test with package access constructor
+ *
+ */
+ ProxyTestClassPackageAccessCtor(int[] a, String s, boolean b) {
+ arr=a;
+ str=s;
+ bool=b;
+ };
+
+ public String getMessage() {
+ return str;
+ }
+}
Propchange:
aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassPackageAccessCtor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassPackageAccessCtor.java
------------------------------------------------------------------------------
svn:executable = *