Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-5914

Workaround SecurityManager.getClassContext returning null on Android

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • framework-6.0.1
    • framework-6.0.2
    • Framework
    • None
    • Important

    Description

      The class SecurityManagerEx is a wrapper class around java.lang.SecurityManager so that it can expose access to the protected method getClassContext which returns a Class[].

      The code as it currently is coded looks like this:

      public Class[] getClassContext()
      {return super.getClassContext(); }

      It looks fine, however, super.getClassContext() at least in the Android implementation returns null.  Here's the Android's implementation code for java.lanaguage.SecurityManager:

      public Object getSecurityContext() {
      return null;
      }

      SecurityManager.getClassContent() is called in the class BundleWiringImpl in the method 

      private Object tryImplicitBootDelegation(final String name, final boolean isClass)

      it passes the result of SecurityManager.getClassContent() (which is null - parameter name classes) to the method doImplicitBootDelegation.  Here's what that code looks like:

      private Object doImplicitBootDelegation(Class[] classes, String name, boolean isClass)
      throws ClassNotFoundException, ResourceNotFoundException
      {
      // Start from 1 to skip security manager class. for (int i = 1; i < classes.length; i++)

      Since classes is null,  classes.length throws an exception. This problem has in my case caused a bundleActivator not to be found.

      The best solution to the problem is to modify the SecurityManagerEx.getClassContext routine to the following:

      public Class[] getClassContext()
      {
      Class[] classes = super.getClassContext();
      if (classes == null) classes = new Class[0];
      return classes;
      }

      Attachments

        Activity

          People

            karlpauls Karl Pauls
            tom@phinneyridge.com Tom Rutchik
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 0.5h
                0.5h
                Remaining:
                Remaining Estimate - 0.5h
                0.5h
                Logged:
                Time Spent - Not Specified
                Not Specified