You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/09/12 15:21:12 UTC
svn commit: r1624541 - in
/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel: Constants.java
classfile/AnnotationDefault.java classfile/ClassParser.java
classfile/JavaClass.java
Author: markt
Date: Fri Sep 12 13:21:12 2014
New Revision: 1624541
URL: http://svn.apache.org/r1624541
Log:
Clean up merge errors and align code wth trunk
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/Constants.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/Constants.java?rev=1624541&r1=1624540&r2=1624541&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/Constants.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/Constants.java Fri Sep 12 13:21:12 2014
@@ -92,7 +92,6 @@ public interface Constants {
"CONSTANT_MethodType", "", "CONSTANT_InvokeDynamic" };
-
/** Attributes and their corresponding names.
*/
public static final byte ATTR_UNKNOWN = -1;
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java?rev=1624541&r1=1624540&r2=1624541&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java Fri Sep 12 13:21:12 2014
@@ -29,7 +29,6 @@ import java.io.IOException;
public class AnnotationDefault extends Attribute
{
private static final long serialVersionUID = 6715933396664171543L;
- ElementValue default_value;
/**
* @param name_index
@@ -46,6 +45,7 @@ public class AnnotationDefault extends A
throws IOException
{
super(name_index, length, constant_pool);
- default_value = ElementValue.readElementValue(file, constant_pool);
+ // Default value
+ ElementValue.readElementValue(file, constant_pool);
}
}
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java?rev=1624541&r1=1624540&r2=1624541&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/ClassParser.java Fri Sep 12 13:21:12 2014
@@ -19,11 +19,8 @@ package org.apache.tomcat.util.bcel.clas
import java.io.BufferedInputStream;
import java.io.DataInputStream;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
import org.apache.tomcat.util.bcel.Constants;
@@ -46,15 +43,12 @@ public final class ClassParser {
private static final int MAGIC = 0xCAFEBABE;
private DataInputStream file;
- private boolean fileOwned;
private String file_name;
- private String zip_file;
private int class_name_index, superclass_name_index;
private int access_flags; // Access rights of parsed class
private int[] interfaces; // Names of implemented interfaces
private ConstantPool constant_pool; // collection of constants
private Attribute[] attributes; // attributes defined in the class
- private boolean is_zip; // Loaded from zip file
private static final int BUFSIZE = 8192;
@@ -66,9 +60,6 @@ public final class ClassParser {
*/
public ClassParser(InputStream file, String file_name) {
this.file_name = file_name;
- fileOwned = false;
- String clazz = file.getClass().getName(); // Not a very clean solution ...
- is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar.");
if (file instanceof DataInputStream) {
this.file = (DataInputStream) file;
} else {
@@ -89,72 +80,40 @@ public final class ClassParser {
* @throws ClassFormatException
*/
public JavaClass parse() throws IOException, ClassFormatException {
- ZipFile zip = null;
- try {
- if (fileOwned) {
- if (is_zip) {
- zip = new ZipFile(zip_file);
- ZipEntry entry = zip.getEntry(file_name);
-
- if (entry == null) {
- throw new IOException("File " + file_name + " not found");
- }
-
- file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry),
- BUFSIZE));
- } else {
- file = new DataInputStream(new BufferedInputStream(new FileInputStream(
- file_name), BUFSIZE));
- }
- }
- /****************** Read headers ********************************/
- // Check magic tag of class file
- readID();
- // Get compiler version
- readVersion();
- /****************** Read constant pool and related **************/
- // Read constant pool entries
- readConstantPool();
- // Get class information
- readClassInfo();
- // Get interface information, i.e., implemented interfaces
- readInterfaces();
- /****************** Read class fields and methods ***************/
- // Read class fields, i.e., the variables of the class
- readFields();
- // Read class methods, i.e., the functions in the class
- readMethods();
- // Read class attributes
- readAttributes();
- // Check for unknown variables
- //Unknown[] u = Unknown.getUnknownAttributes();
- //for(int i=0; i < u.length; i++)
- // System.err.println("WARNING: " + u[i]);
- // Everything should have been read now
- // if(file.available() > 0) {
- // int bytes = file.available();
- // byte[] buf = new byte[bytes];
- // file.read(buf);
- // if(!(is_zip && (buf.length == 1))) {
- // System.err.println("WARNING: Trailing garbage at end of " + file_name);
- // System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf));
- // }
- // }
- } finally {
- // Read everything of interest, so close the file
- if (fileOwned) {
- try {
- if (file != null) {
- file.close();
- }
- if (zip != null) {
- zip.close();
- }
- } catch (IOException ioe) {
- //ignore close exceptions
- }
- }
- }
+ /****************** Read headers ********************************/
+ // Check magic tag of class file
+ readID();
+ // Get compiler version
+ readVersion();
+ /****************** Read constant pool and related **************/
+ // Read constant pool entries
+ readConstantPool();
+ // Get class information
+ readClassInfo();
+ // Get interface information, i.e., implemented interfaces
+ readInterfaces();
+ /****************** Read class fields and methods ***************/
+ // Read class fields, i.e., the variables of the class
+ readFields();
+ // Read class methods, i.e., the functions in the class
+ readMethods();
+ // Read class attributes
+ readAttributes();
+ // Check for unknown variables
+ //Unknown[] u = Unknown.getUnknownAttributes();
+ //for(int i=0; i < u.length; i++)
+ // System.err.println("WARNING: " + u[i]);
+ // Everything should have been read now
+ // if(file.available() > 0) {
+ // int bytes = file.available();
+ // byte[] buf = new byte[bytes];
+ // file.read(buf);
+ // if(!(is_zip && (buf.length == 1))) {
+ // System.err.println("WARNING: Trailing garbage at end of " + file_name);
+ // System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf));
+ // }
+ // }
+
// Return the information we have gathered in a new object
return new JavaClass(class_name_index, superclass_name_index,
access_flags, constant_pool, interfaces, attributes);
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java?rev=1624541&r1=1624540&r2=1624541&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/bcel/classfile/JavaClass.java Fri Sep 12 13:21:12 2014
@@ -97,8 +97,7 @@ public class JavaClass extends AccessFla
if (annotationsOutOfDate) {
// Find attributes that contain annotation data
List<AnnotationEntry> accumulatedAnnotations = new ArrayList<AnnotationEntry>();
- for (int i = 0; i < attributes.length; i++) {
- Attribute attribute = attributes[i];
+ for (Attribute attribute : attributes) {
if (attribute instanceof Annotations) {
Annotations runtimeAnnotations = (Annotations)attribute;
for(int j = 0; j < runtimeAnnotations.getAnnotationEntries().length; j++)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org