예제 #1
0
  public boolean isTooBig(ClassDescriptor desc) {
    IAnalysisCache analysisCache = Global.getAnalysisCache();

    try {
      ClassContext classContext = analysisCache.getClassAnalysis(ClassContext.class, desc);
      ClassData classData = analysisCache.getClassAnalysis(ClassData.class, desc);
      if (classData.getData().length > 1000000) {
        return true;
      }
      try {
        JavaClass javaClass = classContext.getJavaClass();
        if (javaClass.getMethods().length > 1000) {
          return true;
        }
      } catch (RuntimeException e) {
        AnalysisContext.logError(
            "Error parsing class " + desc + " from " + classData.getCodeBaseEntry().getCodeBase(),
            e);
        return true;
      }

    } catch (RuntimeException e) {
      AnalysisContext.logError("Error getting class data for " + desc, e);
      return true;
    } catch (CheckedAnalysisException e) {
      AnalysisContext.logError("Could not get class context for " + desc, e);
      return true;
    }
    return false;
  }
예제 #2
0
  @Test(expected = RuntimeException.class)
  public void shouldFailOnNoBeanClass() throws NoSuchMethodException {
    // GIVEN
    SampleController ctrl = new SampleController() {};
    final Method method = ctrl.getClass().getMethod("writeMethod");
    // WHEN
    final ClassContext ctx = new ClassContext(ctrl.getClass());

    ctx.performTransaction(ctrl, method, new Object[] {});
  }
예제 #3
0
 public static void main(String[] args) {
   ClassContext cContext = new ClassContext(new EmptyRoomState());
   System.out.println(cContext.getState());
   cContext.enter();
   System.out.println(cContext.getState());
   cContext.enter();
   System.out.println(cContext.getState());
 }
예제 #4
0
 private boolean isRequestFromVM() {
   if (bundle.getFramework().isBootDelegationPackage("*")
       || !bundle.getFramework().contextBootDelegation) // $NON-NLS-1$
   return false;
   // works around VM bugs that require all classloaders to have access to parent packages
   Class[] context = CLASS_CONTEXT.getClassContext();
   if (context == null || context.length < 2) return false;
   // skip the first class; it is the ClassContext class
   for (int i = 1; i < context.length; i++)
     // find the first class in the context which is not BundleLoader or instanceof ClassLoader
     if (context[i] != BundleLoader.class && !ClassLoader.class.isAssignableFrom(context[i])) {
       // only find in parent if the class is not "Class" (Class#forName case) or if the class is
       // not loaded with a BundleClassLoader
       ClassLoader cl = getClassLoader(context[i]);
       if (cl
           != FW_CLASSLOADER) { // extra check incase an adaptor adds another class into the stack
         // besides an instance of ClassLoader
         if (Class.class != context[i] && !(cl instanceof BundleClassLoader)) return true;
         break;
       }
     }
   return false;
 }
예제 #5
0
 public void enterClass(ClassContext classContext) {
   classContext.setState(new EnteredRoomState());
 }
예제 #6
0
 public void enterClass(ClassContext labContext) {
   labContext.setState(new EmptyRoomState());
 }