ClassLoader.isAncestorOf(ClassLoader) Bug

by Daniel Janev » Tue, 24 Mar 2009 21:52:24 GMT


Sponsored Links
 Hello All,

Please someone from Google to comment this issue!

My colleagues has found a bug in the java.lang.ClassLoader
implementation of the cupcake tag of the Android platform. Here is a
short descriptions:

We try to invoke ClassLoader.getSystemClassLoader() in one of our OSGi
implementation classes and afterwards we have endless loop. Here are the
bodies of the methods:

public static ClassLoader getSystemClassLoader() {
  SecurityManager smgr = System.getSecurityManager();

  if (smgr != null) {
    ClassLoader caller = VMStack.getCallingClassLoader();
    if (caller != null && !caller.isAncestorOf(SystemClassLoader.loader)) {
      smgr.checkPermission(new RuntimePermission("getClassLoader"));
    }
  }
  return SystemClassLoader.loader;
}
...
and in isAncestorOf method we have:

final boolean isAncestorOf(ClassLoader child) {
  for (ClassLoader current = child; current != null; current =
child.parent) {
    if (current == this) {
      return true;
    }
  }
  return false;
}

In a dynamic environment like an OSGi implementation with set security
manager the isAncestorOf(...) follows to an endless loop. As you can see
- if the child is a custom class loader, which has another class loader
as a parent. The problem is that current is always is set to
child.parent but the child is never changed. The following code fixes
the problem:

final boolean isAncestorOf(ClassLoader child) {
  for (ClassLoader current = child; current != null; current =
current.parent) {
    if (current == this) {
      return true;
    }
  }
  return false;
}

I hope that you will be able to fix this as soon as possible and to
update the cupcake branch too. Please notify me when this is ready.

Thanks in advance!!

-- 

Best Regards,
    Daniel
---------------------------------------------------------------
Daniel Janev  Department Manager/Core Platform and Smart Home
ProSyst Software GmbH
1606 Sofia, Bulgaria  Vladajska Str. 48
Tel. +359 (0)2 952 35 81/109  Fax +359 (0)2 953 26 17
Mobile Phone +359 (0)888 678 670
 http://www.prosyst.com   d.ja...@prosyst.com
---------------------------------------------------------------
stay in touch with your product.
---------------------------------------------------------------

--~--~---------~--~----~------------~-------~--~----~



ClassLoader.isAncestorOf(ClassLoader) Bug

by Mark Murphy » Tue, 24 Mar 2009 22:00:35 GMT


 


Did you file this on  http://b.android.com ? That is the issue tracker for
Android. I do not see your issue out there, so I strongly encourage you
to file it there.


If you would take the time to file this on  http://b.android.com , you
will automatically be notified of progress on the issue.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Warescription: Three Android Books, Plus Updates, $35/Year

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


ClassLoader.isAncestorOf(ClassLoader) Bug

by Daniel Janev » Tue, 24 Mar 2009 22:14:12 GMT


 Thanks Mark,

I've posted the bug there.







-- 

Best Regards,
    Daniel
---------------------------------------------------------------
Daniel Janev  Department Manager/Core Platform and Smart Home
ProSyst Software GmbH
1606 Sofia, Bulgaria  Vladajska Str. 48
Tel. +359 (0)2 952 35 81/109  Fax +359 (0)2 953 26 17
Mobile Phone +359 (0)888 678 670
 http://www.prosyst.com   d.ja...@prosyst.com
---------------------------------------------------------------
stay in touch with your product.
---------------------------------------------------------------

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. about android Reversepengineering !!!!

My English is just so-so .   I dont 'want to  other people
reversepengineering. my android app. how should I do?

-- 

2. Android SDK components download fails

I am trying to add Android SDK components. After installing Android
SDK Starter Package and setting up proxy when I click on "Available
Packages" Android SDK and AVD Manager fails to fetch from repository.
I tried with both https and http. I tried to access this site (http://
dl-ssl.google.com/android) in my browser also but it shows "Not
Found". I can access other sites without any problem.
Any help?

thanks,
Lomesh

-- 

3. Tween animation deactivates button

4. camera preview with graphics on top

5. Problem with installing Android SDK

6. binding to a service from a separate class

7. Is there any good code coverage tool apart from EMMA?