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; }
@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[] {}); }
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()); }
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; }
public void enterClass(ClassContext classContext) { classContext.setState(new EnteredRoomState()); }
public void enterClass(ClassContext labContext) { labContext.setState(new EmptyRoomState()); }