use of com.jopdesign.common.misc.MethodNotFoundException in project jop by jop-devel.
the class AppInfo method getMethodInfos.
/**
* @param memberID at least a class name.
* @return a set of all matching methods.
* @throws MethodNotFoundException if the base class cannot be found
*/
public Collection<MethodInfo> getMethodInfos(MemberID memberID) throws MethodNotFoundException {
String className = memberID.getClassName();
ClassInfo classInfo = classes.get(className);
if (classInfo == null) {
throw new MethodNotFoundException("Could not find class for method " + memberID);
}
if (!memberID.hasMemberName()) {
// We could filter out methods by descriptor if it is set
return classInfo.getMethods();
}
return classInfo.getMethodInfos(memberID);
}
use of com.jopdesign.common.misc.MethodNotFoundException in project jop by jop-devel.
the class Config method parseMethodList.
/**
* @param methodNames comma separated list of method names, either fully qualified with or without descriptor, or
* method names of methods in the main class.
* @return the set of methods represented by these names
* @throws BadConfigurationException if a name is not resolvable
*/
public static List<MethodInfo> parseMethodList(String methodNames) throws BadConfigurationException {
List<String> names = splitStringList(methodNames);
List<MethodInfo> methods = new ArrayList<MethodInfo>(names.size());
for (String name : names) {
MemberID id = MemberID.parse(name);
if (!id.hasClassName()) {
ClassInfo main = AppInfo.getSingleton().getMainMethod().getClassInfo();
Set<MethodInfo> m = main.getMethodInfos(id);
if (m.isEmpty()) {
throw new BadConfigurationException("Cannot find method '" + name + "' in main class " + main);
}
methods.addAll(m);
} else {
try {
Collection<MethodInfo> infos = AppInfo.getSingleton().getMethodInfos(id);
if (infos.isEmpty()) {
throw new BadConfigurationException("Cannot find methods for " + name);
}
methods.addAll(infos);
} catch (MethodNotFoundException e) {
throw new BadConfigurationException("Cannot find class for " + name, e);
}
}
}
return methods;
}
use of com.jopdesign.common.misc.MethodNotFoundException in project jop by jop-devel.
the class SourceLineStorage method loadSourceInfos.
/**
* Load all source file and -line annotations for all classes from the storage file.
*/
public void loadSourceInfos() {
if (sourceLineMap == null) {
try {
readSourceInfos();
} catch (IOException e) {
logger.error("Error reading sourceline file " + storage, e);
}
}
Map<MethodInfo, List<SourceLineEntry>> methodMap = new HashMap<MethodInfo, List<SourceLineEntry>>(sourceLineMap.size());
for (MemberID mID : sourceLineMap.keySet()) {
try {
MethodInfo method = AppInfo.getSingleton().getMethodInfo(mID);
methodMap.put(method, sourceLineMap.get(mID));
} catch (MethodNotFoundException ignored) {
logger.warn("No method for entry " + mID + " in " + storage + " found!");
}
}
for (MethodInfo method : methodMap.keySet()) {
try {
if (AppInfo.getSingleton().getClassFile(method.getClassInfo()).getTime() > storage.lastModified()) {
logger.error("One or more class files are newer than annotation file " + storage + ", not loading source line annotations!");
return;
}
} catch (FileNotFoundException e) {
logger.error("Could not get class file for class " + method.getClassInfo() + ", not loading source lines!", e);
return;
}
}
for (Map.Entry<MethodInfo, List<SourceLineEntry>> entry : methodMap.entrySet()) {
MethodInfo method = entry.getKey();
applySourceInfos(method, entry.getValue());
}
}
Aggregations