Source:
<code>private Object loadClass(String className, Class[] constructorSignature, Object[] constructorArgs, boolean isView) { Class<?> aClass = myLoadedClasses.get(className); Integer nestedOccurrences = null; try { if (aClass != null) { checkModified(className); return createNewInstance(aClass, constructorSignature, constructorArgs, isView); } aClass = loadClass(className); if (aClass != null) { checkModified(className); <START> nestedOccurrences = myLoadingClasses.get(aClass); <END> myLoadingClasses.put(aClass, nestedOccurrences == null ? 1 : nestedOccurrences + 1); if (nestedOccurrences != null && nestedOccurrences > 100) { throw new InstantiationException(className + " has infinite recursion."); } final Object viewObject = createNewInstance(aClass, constructorSignature, constructorArgs, isView); myLoadedClasses.put(className, aClass); return viewObject; } } catch (InconvertibleClassError e) { myLogger.addIncorrectFormatClass(e.getClassName(), e); } catch (LinkageError e) { myLogger.addBrokenClass(className, e); } catch (ClassNotFoundException e) { myLogger.addBrokenClass(className, e); } catch (InvocationTargetException e) { final Throwable cause = e.getCause(); if (cause instanceof InconvertibleClassError) { InconvertibleClassError error = (InconvertibleClassError)cause; myLogger.addIncorrectFormatClass(error.getClassName(), error); } else { myLogger.addBrokenClass(className, cause); } } catch (IllegalAccessException e) { myLogger.addBrokenClass(className, e); } catch (InstantiationException e) { myLogger.addBrokenClass(className, e); } catch (NoSuchMethodException e) { myLogger.addBrokenClass(className, e); } finally { if (nestedOccurrences == null) { myLoadingClasses.remove(aClass); } else { myLoadingClasses.put(aClass, nestedOccurrences); } } return null; }</code><technical_language>a Multiset simplify this</technical_language>

Target:
private Object loadClass(String className, Class[] constructorSignature, Object[] constructorArgs, boolean isView) { Class<?> aClass = myLoadedClasses.get(className); int nestedOccurrences = 0; try { if (aClass != null) { checkModified(className); return createNewInstance(aClass, constructorSignature, constructorArgs, isView); } aClass = loadClass(className); if (aClass != null) { checkModified(className); nestedOccurrences = myLoadingClasses.count(aClass); myLoadingClasses.add(aClass); if (nestedOccurrences > 100) { throw new InstantiationException(className + " has infinite recursion."); } final Object viewObject = createNewInstance(aClass, constructorSignature, constructorArgs, isView); myLoadedClasses.put(className, aClass); return viewObject; } } catch (InconvertibleClassError e) { myLogger.addIncorrectFormatClass(e.getClassName(), e); } catch (LinkageError e) { myLogger.addBrokenClass(className, e); } catch (ClassNotFoundException e) { myLogger.addBrokenClass(className, e); } catch (InvocationTargetException e) { final Throwable cause = e.getCause(); if (cause instanceof InconvertibleClassError) { InconvertibleClassError error = (InconvertibleClassError)cause; myLogger.addIncorrectFormatClass(error.getClassName(), error); } else { myLogger.addBrokenClass(className, cause); } } catch (IllegalAccessException e) { myLogger.addBrokenClass(className, e); } catch (InstantiationException e) { myLogger.addBrokenClass(className, e); } catch (NoSuchMethodException e) { myLogger.addBrokenClass(className, e); } finally { if (nestedOccurrences != 0) { myLoadingClasses.remove(aClass); } } return null; }