}
InputStream is = JdtUtils.createInputStream(type);
if (is == null) {
return null;
}
DecompiledClass decompiledClass = null;
int available = 0;
try {
ClassLoader cl = null;
if (modes.get(BCOConstants.F_SHOW_ANALYZER)) {
cl = JdtUtils.getClassLoader(type);
}
String fieldName = null;
String methodName = null;
/*
* find out, which name we should use for selected element
*/
if (modes.get(BCOConstants.F_SHOW_ONLY_SELECTED_ELEMENT)
&& childEl != null) {
if (childEl.getElementType() == IJavaElement.FIELD) {
fieldName = childEl.getElementName();
} else {
methodName = JdtUtils.getMethodSignature(childEl);
}
}
available = is.available();
decompiledClass = DecompilerClassVisitor.getDecompiledClass(
is, fieldName, methodName, modes, cl);
} catch (Exception e) {
try {
// check if compilation unit is ok - then this is the user problem
if (type.isStructureKnown()) {
BytecodeOutlinePlugin.error("Cannot decompile: " + type, e);
} else {
BytecodeOutlinePlugin.log(e, IStatus.ERROR);
}
} catch (JavaModelException e1) {
// this is compilation problem - don't show the message
BytecodeOutlinePlugin.log(e1, IStatus.WARNING);
}
} catch (UnsupportedClassVersionError e) {
BytecodeOutlinePlugin.error("Cannot decompile: " + type
+ ". Error was caused by attempt to "
+ "load a class compiled with the Java version which is not "
+ "supported by the current JVM. ", e);
} finally {
try {
is.close();
} catch (IOException e) {
BytecodeOutlinePlugin.log(e, IStatus.WARNING);
}
}
// remember class file size to show it later in UI
if (decompiledClass != null) {
decompiledClass.setAttribute(DecompiledClass.ATTR_CLAS_SIZE, ""
+ available);
}
return decompiledClass;
}