Skip to content

Commit

Permalink
Catch ASM ClassReader's IllegalArgumentException and turn it into a m…
Browse files Browse the repository at this point in the history
…ore expressive exception, hinting at the class file version

Issue: SPR-10292
  • Loading branch information
jhoeller committed Feb 15, 2013
1 parent add6a7f commit 5e64723
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@
import java.io.InputStream;

import org.springframework.asm.ClassReader;
import org.springframework.core.NestedIOException;
import org.springframework.core.io.Resource;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.ClassMetadata;
Expand All @@ -47,10 +48,14 @@ final class SimpleMetadataReader implements MetadataReader {

SimpleMetadataReader(Resource resource, ClassLoader classLoader) throws IOException {
InputStream is = new BufferedInputStream(resource.getInputStream());
ClassReader classReader = null;
ClassReader classReader;
try {
classReader = new ClassReader(is);
}
catch (IllegalArgumentException ex) {
throw new NestedIOException("ASM ClassReader failed to parse class file - " +
"probably due to a new Java class file version that isn't supported yet: " + resource, ex);
}
finally {
is.close();
}
Expand All @@ -64,6 +69,7 @@ final class SimpleMetadataReader implements MetadataReader {
this.resource = resource;
}


public Resource getResource() {
return this.resource;
}
Expand Down

0 comments on commit 5e64723

Please sign in to comment.