This task is about a basic decompiler and how could i fill in the following several methods marked as comment? thanks
getMethodInfo() returns a string object which contains the method header(visibility, modifiers, return type, name, parameter list)
getClassInfo() returns a string object representing the head of the class definition without the { opening for the body
getFieldInfo() returns a string object containing the definition of a given field without a potential initialization value.
getConstructorInfo() returns a string object containing the definition of a given constructor, including parameters.
public String decompile(Class<?> clazz) {
StringBuilder stringBuilder = new StringBuilder(getClassInfo(clazz))
.append("{");
/* iterate over all constructors and add them to the output string */
/* iterate over all fields and add them to the output string */
/* iterate over all methods and add them to the output string */
stringBuilder.append("\n}");
return stringBuilder.toString();
}
public String getClassInfo(Class<?> clazz) {
StringBuilder stringBuilder = new StringBuilder();
/* implement getClassInfo() */
return stringBuilder.toString();
}
public String getFieldInfo(Field field) {
StringBuilder stringBuilder = new StringBuilder();
/* implement getFieldInfo() */
return stringBuilder.toString();
}
public String getConstructorInfo(Constructor<?> constructor) {
StringBuilder stringBuilder = new StringBuilder();
/* implement getConstructorInfo() */
/* return final string */
return stringBuilder.toString();
}
public String getMethodInfo(Method method) {
StringBuilder stringBuilder = new StringBuilder();
/* implement getMethodInfo() */
return stringBuilder.toString();
}
}
Aucun commentaire:
Enregistrer un commentaire