Fix Object has null Constructor

This commit is contained in:
JanUlrich 2021-05-27 12:09:46 +02:00
parent 18d9edfeea
commit 00add07132

View File

@ -36,7 +36,7 @@ public class ASTFactory {
List<Method> methoden = new ArrayList<>(); List<Method> methoden = new ArrayList<>();
List<de.dhbwstuttgart.syntaxtree.Constructor> konstruktoren = new ArrayList<>(); List<de.dhbwstuttgart.syntaxtree.Constructor> konstruktoren = new ArrayList<>();
for(java.lang.reflect.Constructor constructor : jreClass.getConstructors()){ for(java.lang.reflect.Constructor constructor : jreClass.getConstructors()){
konstruktoren.add(createConstructor(constructor, jreClass)); createConstructor(constructor, jreClass).map(c -> konstruktoren.add(c));
} }
Set<java.lang.reflect.Method> allMethods = new HashSet<>(Arrays.asList(jreClass.getMethods())); Set<java.lang.reflect.Method> allMethods = new HashSet<>(Arrays.asList(jreClass.getMethods()));
Set<java.lang.reflect.Method> allDeclaredMethods = new HashSet<>(Arrays.asList(jreClass.getDeclaredMethods())); Set<java.lang.reflect.Method> allDeclaredMethods = new HashSet<>(Arrays.asList(jreClass.getDeclaredMethods()));
@ -87,7 +87,7 @@ public class ASTFactory {
// return createClass(classType).getType(); // return createClass(classType).getType();
//} //}
private static de.dhbwstuttgart.syntaxtree.Constructor createConstructor(Constructor constructor, Class inClass) { private static Optional<de.dhbwstuttgart.syntaxtree.Constructor> createConstructor(Constructor constructor, Class inClass) {
String name = constructor.getName(); String name = constructor.getName();
RefTypeOrTPHOrWildcardOrGeneric returnType = createType(inClass); RefTypeOrTPHOrWildcardOrGeneric returnType = createType(inClass);
Parameter[] jreParams = constructor.getParameters(); Parameter[] jreParams = constructor.getParameters();
@ -106,10 +106,10 @@ public class ASTFactory {
int modifier = constructor.getModifiers(); int modifier = constructor.getModifiers();
if(inClass.equals(java.lang.Object.class)){ if(inClass.equals(java.lang.Object.class)){
return null; return Optional.empty();
} }
return new de.dhbwstuttgart.syntaxtree.Constructor(modifier, name,returnType, parameterList, block, gtvDeclarations, offset /*, new ArrayList<>() geloescht PL 2018-11-24 */); return Optional.of(new de.dhbwstuttgart.syntaxtree.Constructor(modifier, name,returnType, parameterList, block, gtvDeclarations, offset /*, new ArrayList<>() geloescht PL 2018-11-24 */));
} }
public static Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass, Boolean isInherited){ public static Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass, Boolean isInherited){