You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by dj...@apache.org on 2011/05/28 04:24:20 UTC

svn commit: r1128548 - /aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/OSGiFriendlyClassWriter.java

Author: djencks
Date: Sat May 28 02:24:19 2011
New Revision: 1128548

URL: http://svn.apache.org/viewvc?rev=1128548&view=rev
Log:
ARIES-666 throw an UnableToProxyException instead of giving up when a superclass is missing from the current bundle.  Needs review

Modified:
    aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/OSGiFriendlyClassWriter.java

Modified: aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/OSGiFriendlyClassWriter.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/OSGiFriendlyClassWriter.java?rev=1128548&r1=1128547&r2=1128548&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/OSGiFriendlyClassWriter.java (original)
+++ aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/OSGiFriendlyClassWriter.java Sat May 28 02:24:19 2011
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.aries.proxy.UnableToProxyException;
 import org.apache.aries.proxy.impl.NLS;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassWriter;
@@ -79,37 +80,45 @@ final class OSGiFriendlyClassWriter exte
       boolean bRunning = true;
       boolean aRunning = true;
       InputStream is;
-      
+      String arg00 = arg0;
+      String arg11 = arg1;
+      String unable = null;
       while(aRunning || bRunning ) {
         if(aRunning) {
-          is = loader.getResourceAsStream(arg0 + ".class");
+          is = loader.getResourceAsStream(arg00 + ".class");
           if(is != null) {
             ClassReader cr = new ClassReader(is);
-            arg0 = cr.getSuperName();
-            if(arg0 == null)
+            arg00 = cr.getSuperName();
+            if(arg00 == null)
               aRunning = false;
-            else if(!!!names.add(arg0))
-              return arg0;
+            else if(!!!names.add(arg00))
+              return arg00;
           } else {
+            unable = arg0;
             aRunning = false;
           }
         }
         if(bRunning) {
-          is = loader.getResourceAsStream(arg1 + ".class");
+          is = loader.getResourceAsStream(arg11 + ".class");
           if(is != null) {
             ClassReader cr = new ClassReader(is);
-            arg1 = cr.getSuperName();
-            if(arg1 == null)
+            arg11 = cr.getSuperName();
+            if(arg11 == null)
               bRunning = false;
-            else if(!!!names.add(arg1))
-              return arg1;
+            else if(!!!names.add(arg11))
+              return arg11;
           } else {
+            unable = arg1;
             bRunning = false;
           }
         }
       }
-      
-      throw new RuntimeException(NLS.MESSAGES.getMessage("no.common.superclass", arg0, arg1));
+
+        if (unable == null) {
+            throw new RuntimeException(NLS.MESSAGES.getMessage("no.common.superclass", arg0, arg1));
+        } else {
+            throw new RuntimeException(new UnableToProxyException(unable, NLS.MESSAGES.getMessage("no.common.superclass", arg0, arg1)));
+        }
     } catch (IOException e) {
       throw new RuntimeException(e);
     }



Re: svn commit: r1128548 - /aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/OSGiFriendlyClassWriter.java

Posted by David Jencks <da...@yahoo.com>.
On May 28, 2011, at 9:52 AM, Jacek Laskowski wrote:

> On Sat, May 28, 2011 at 4:24 AM,  <dj...@apache.org> wrote:
> 
>> +            else if(!!!names.add(arg00))
> 
> Hi Dave,
> 
> I'm curious why there're three !'s above? I've never seen it before
> and I have a gut feeling that I need to master this magic :)
> 
> Jacek
> 
Hi Jarek,

I didn't put it there :-)

It means the same as one !.  I think someone told me once that they did it because it was easier to see when glancing over the code.  Personally I don't like it much but it seems endemic in aries.

david jencks


Re: svn commit: r1128548 - /aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/weaving/OSGiFriendlyClassWriter.java

Posted by Jacek Laskowski <ja...@japila.pl>.
On Sat, May 28, 2011 at 4:24 AM,  <dj...@apache.org> wrote:

> +            else if(!!!names.add(arg00))

Hi Dave,

I'm curious why there're three !'s above? I've never seen it before
and I have a gut feeling that I need to master this magic :)

Jacek

-- 
Jacek Laskowski
Java EE, functional languages and IBM WebSphere - http://blog.japila.pl
Warszawa JUG conference = Confitura (formerly Javarsovia) :: http://confitura.pl