mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8333812: ClassFile.verify() can throw exceptions instead of returning VerifyErrors
Reviewed-by: liach
This commit is contained in:
parent
6e9fcc2d80
commit
c25c4896ad
4 changed files with 44 additions and 7 deletions
|
@ -286,7 +286,11 @@ public abstract sealed class BoundAttribute<T extends Attribute<T>>
|
|||
|
||||
public BoundLocalVariableTableAttribute(AttributedElement enclosing, ClassReader cf, AttributeMapper<LocalVariableTableAttribute> mapper, int pos) {
|
||||
super(cf, mapper, pos);
|
||||
codeAttribute = (CodeImpl) enclosing;
|
||||
if (enclosing instanceof CodeImpl ci) {
|
||||
this.codeAttribute = ci;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid LocalVariableTable attribute location");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -313,7 +317,11 @@ public abstract sealed class BoundAttribute<T extends Attribute<T>>
|
|||
|
||||
public BoundLocalVariableTypeTableAttribute(AttributedElement enclosing, ClassReader cf, AttributeMapper<LocalVariableTypeTableAttribute> mapper, int pos) {
|
||||
super(cf, mapper, pos);
|
||||
this.codeAttribute = (CodeImpl) enclosing;
|
||||
if (enclosing instanceof CodeImpl ci) {
|
||||
this.codeAttribute = ci;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid LocalVariableTypeTable attribute location");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -132,7 +132,11 @@ public record ClassFileImpl(StackMapsOption stackMapsOption,
|
|||
|
||||
@Override
|
||||
public List<VerifyError> verify(ClassModel model) {
|
||||
return VerifierImpl.verify(model, classHierarchyResolverOption().classHierarchyResolver(), null);
|
||||
try {
|
||||
return VerifierImpl.verify(model, classHierarchyResolverOption().classHierarchyResolver(), null);
|
||||
} catch (IllegalArgumentException verifierInitializationError) {
|
||||
return List.of(new VerifyError(verifierInitializationError.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -114,9 +114,10 @@ public final class VerifierImpl {
|
|||
}
|
||||
|
||||
public static List<VerifyError> verify(ClassModel classModel, ClassHierarchyResolver classHierarchyResolver, Consumer<String> logger) {
|
||||
var klass = new VerificationWrapper(classModel);
|
||||
log_info(logger, "Start class verification for: %s", klass.thisClassName());
|
||||
String clsName = classModel.thisClass().asInternalName();
|
||||
log_info(logger, "Start class verification for: %s", clsName);
|
||||
try {
|
||||
var klass = new VerificationWrapper(classModel);
|
||||
var errors = new ArrayList<VerifyError>();
|
||||
errors.addAll(new ParserVerifier(classModel).verify());
|
||||
if (is_eligible_for_verification(klass)) {
|
||||
|
@ -134,7 +135,7 @@ public final class VerifierImpl {
|
|||
}
|
||||
return errors;
|
||||
} finally {
|
||||
log_info(logger, "End class verification for: %s", klass.thisClassName());
|
||||
log_info(logger, "End class verification for: %s", clsName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue