/** * Returns the list of exception types caught by this catch block. * Any of these can be null, if they couldn't be resolved. This can * happen if the auxclasspath is not correctly set. */ @SuppressWarnings("unchecked") public List<Class<? extends Exception>> getCaughtExceptionTypes() { List<Class<? extends Exception>> result = new ArrayList<>(); for (ASTType type : getCaughtExceptionTypeNodes()) { result.add((Class<? extends Exception>) type.getType()); } return result; }
private boolean isSerializationMethod(ASTMethodDeclaration node) { ASTMethodDeclarator declarator = node.getFirstDescendantOfType(ASTMethodDeclarator.class); List<ASTFormalParameter> parameters = declarator.findDescendantsOfType(ASTFormalParameter.class); if (node.isPrivate() && "readObject".equals(node.getMethodName()) && parameters.size() == 1 && throwsOneException(node, InvalidObjectException.class)) { ASTType type = parameters.get(0).getTypeNode(); if (type.getType() == ObjectInputStream.class || ObjectInputStream.class.getSimpleName().equals(type.getTypeImage()) || ObjectInputStream.class.getName().equals(type.getTypeImage())) { return true; } } return false; }
return ((TypeNode) typeNode.jjtGetChild(0)).getTypeDefinition(); } else { // primitive type return JavaTypeDefinition.forClass(typeNode.getType());
private boolean isSerializationMethod(ASTMethodDeclaration node) { ASTMethodDeclarator declarator = node.getFirstDescendantOfType(ASTMethodDeclarator.class); List<ASTFormalParameter> parameters = declarator.findDescendantsOfType(ASTFormalParameter.class); if (node.isPrivate() && "readObject".equals(node.getMethodName()) && parameters.size() == 1 && throwsOneException(node, InvalidObjectException.class)) { ASTType type = parameters.get(0).getTypeNode(); if (type.getType() == ObjectInputStream.class || ObjectInputStream.class.getSimpleName().equals(type.getTypeImage()) || ObjectInputStream.class.getName().equals(type.getTypeImage())) { return true; } } return false; }
/** * Returns the list of exception types caught by this catch block. * Any of these can be null, if they couldn't be resolved. This can * happen if the auxclasspath is not correctly set. */ @SuppressWarnings("unchecked") public List<Class<? extends Exception>> getCaughtExceptionTypes() { List<Class<? extends Exception>> result = new ArrayList<>(); for (ASTType type : getCaughtExceptionTypeNodes()) { result.add((Class<? extends Exception>) type.getType()); } return result; }
private boolean returnThread(ASTMethodDeclaration methodDeclaration) { ASTResultType resultType = methodDeclaration.getFirstChildOfType(ASTResultType.class); ASTType type = resultType.getFirstChildOfType(ASTType.class); return type != null && type.getType() == Thread.class; }
private boolean isInNewThreadMethod(ASTAllocationExpression node) { ASTMethodDeclaration methodDeclaration = node.getFirstParentOfType(ASTMethodDeclaration.class); if (methodDeclaration == null) { return false; } if (!returnThread(methodDeclaration)) { return false; } if (!METHOD_NEW_THREAD.equals(methodDeclaration.getMethodName())) { return false; } List<ASTFormalParameter> parameters = methodDeclaration.getFirstDescendantOfType(ASTFormalParameters.class) .findChildrenOfType(ASTFormalParameter.class); return parameters.size() == 1 && parameters.get(0).getFirstChildOfType(ASTType.class).getType() == Runnable.class; }
return ((TypeNode) typeNode.jjtGetChild(0)).getTypeDefinition(); } else { // primitive type return JavaTypeDefinition.forClass(typeNode.getType());