Browse Source

Remove bcel-builder/verifier-src

It looks as if the source code is never built and never used either.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tags/V1_9_22
Alexander Kriegisch 1 month ago
parent
commit
17795394ff
58 changed files with 0 additions and 16161 deletions
  1. 0
    599
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java
  2. 0
    241
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyClassVisitor.java
  3. 0
    259
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyInstVisitor.java
  4. 0
    111
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/GraphicalVerifier.java
  5. 0
    459
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/InstructionWalker.java
  6. 0
    116
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/NativeVerifier.java
  7. 0
    143
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/PassVerifier.java
  8. 0
    137
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/TransitiveHull.java
  9. 0
    135
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerificationResult.java
  10. 0
    288
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/Verifier.java
  11. 0
    409
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierAppFrame.java
  12. 0
    143
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactory.java
  13. 0
    107
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryListModel.java
  14. 0
    76
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryObserver.java
  15. 0
    559
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifyDialog.java
  16. 0
    107
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/AssertionViolatedException.java
  17. 0
    79
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/ClassConstraintException.java
  18. 0
    77
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/CodeConstraintException.java
  19. 0
    69
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/InvalidMethodException.java
  20. 0
    74
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LinkingConstraintException.java
  21. 0
    79
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LoadingException.java
  22. 0
    81
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java
  23. 0
    71
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeConstraintException.java
  24. 0
    74
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java
  25. 0
    74
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java
  26. 0
    82
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StructuralCodeConstraintException.java
  27. 0
    76
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/Utility.java
  28. 0
    82
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/VerificationException.java
  29. 0
    107
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java
  30. 0
    25
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/package.html
  31. 0
    79
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/DOUBLE_Upper.java
  32. 0
    85
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/IntList.java
  33. 0
    79
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LONG_Upper.java
  34. 0
    144
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariableInfo.java
  35. 0
    106
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariablesInfo.java
  36. 0
    215
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass1Verifier.java
  37. 0
    1490
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java
  38. 0
    1188
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass3aVerifier.java
  39. 0
    268
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/StringRepresentation.java
  40. 0
    26
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/package.html
  41. 0
    456
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ControlFlowGraph.java
  42. 0
    93
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandler.java
  43. 0
    108
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandlers.java
  44. 0
    1136
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExecutionVisitor.java
  45. 0
    150
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Frame.java
  46. 0
    66
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/GenericArray.java
  47. 0
    2444
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstConstraintVisitor.java
  48. 0
    141
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstructionContext.java
  49. 0
    229
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/LocalVariables.java
  50. 0
    275
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/OperandStack.java
  51. 0
    377
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Pass3bVerifier.java
  52. 0
    126
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutine.java
  53. 0
    670
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutines.java
  54. 0
    97
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/UninitializedObjectType.java
  55. 0
    27
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/package.html
  56. 0
    366
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELFactory.java
  57. 0
    341
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELifier.java
  58. 0
    440
      bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/InstructionFinder.java

+ 0
- 599
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java View File

@@ -1,599 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/
import java.util.Stack;

import org.aspectj.apache.bcel.classfile.AnnotationDefault;
import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.AttributeUtils;
import org.aspectj.apache.bcel.classfile.BootstrapMethods;
import org.aspectj.apache.bcel.classfile.ClassVisitor;
import org.aspectj.apache.bcel.classfile.Code;
import org.aspectj.apache.bcel.classfile.CodeException;
import org.aspectj.apache.bcel.classfile.Constant;
import org.aspectj.apache.bcel.classfile.ConstantClass;
import org.aspectj.apache.bcel.classfile.ConstantDouble;
import org.aspectj.apache.bcel.classfile.ConstantDynamic;
import org.aspectj.apache.bcel.classfile.ConstantFieldref;
import org.aspectj.apache.bcel.classfile.ConstantFloat;
import org.aspectj.apache.bcel.classfile.ConstantInteger;
import org.aspectj.apache.bcel.classfile.ConstantInterfaceMethodref;
import org.aspectj.apache.bcel.classfile.ConstantInvokeDynamic;
import org.aspectj.apache.bcel.classfile.ConstantLong;
import org.aspectj.apache.bcel.classfile.ConstantMethodHandle;
import org.aspectj.apache.bcel.classfile.ConstantMethodType;
import org.aspectj.apache.bcel.classfile.ConstantMethodref;
import org.aspectj.apache.bcel.classfile.ConstantModule;
import org.aspectj.apache.bcel.classfile.ConstantNameAndType;
import org.aspectj.apache.bcel.classfile.ConstantPackage;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.ConstantString;
import org.aspectj.apache.bcel.classfile.ConstantUtf8;
import org.aspectj.apache.bcel.classfile.ConstantValue;
import org.aspectj.apache.bcel.classfile.Deprecated;
import org.aspectj.apache.bcel.classfile.EnclosingMethod;
import org.aspectj.apache.bcel.classfile.ExceptionTable;
import org.aspectj.apache.bcel.classfile.Field;
import org.aspectj.apache.bcel.classfile.InnerClass;
import org.aspectj.apache.bcel.classfile.InnerClasses;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.LineNumber;
import org.aspectj.apache.bcel.classfile.LineNumberTable;
import org.aspectj.apache.bcel.classfile.LocalVariable;
import org.aspectj.apache.bcel.classfile.LocalVariableTable;
import org.aspectj.apache.bcel.classfile.LocalVariableTypeTable;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.MethodParameters;
import org.aspectj.apache.bcel.classfile.Module;
import org.aspectj.apache.bcel.classfile.ModuleMainClass;
import org.aspectj.apache.bcel.classfile.ModulePackages;
import org.aspectj.apache.bcel.classfile.NestHost;
import org.aspectj.apache.bcel.classfile.NestMembers;
import org.aspectj.apache.bcel.classfile.Signature;
import org.aspectj.apache.bcel.classfile.SourceFile;
import org.aspectj.apache.bcel.classfile.StackMap;
import org.aspectj.apache.bcel.classfile.StackMapEntry;
import org.aspectj.apache.bcel.classfile.Synthetic;
import org.aspectj.apache.bcel.classfile.Unknown;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisParamAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisTypeAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisTypeAnnos;

/**
* Traverses a JavaClass with another Visitor object 'piggy-backed' that is
* applied to all components of a JavaClass object. I.e. this class supplies the
* traversal strategy, other classes can make use of it.
*
* @version $Id: DescendingVisitor.java,v 1.4 2009/09/15 19:40:22 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public class DescendingVisitor implements ClassVisitor {
private JavaClass clazz;
private ClassVisitor visitor;
private Stack<Object> stack = new Stack<Object>();

/**
* @return container of current entitity, i.e., predecessor during traversal
*/
public Object predecessor() {
return predecessor(0);
}

/**
* @param level
* nesting level, i.e., 0 returns the direct predecessor
* @return container of current entitity, i.e., predecessor during traversal
*/
public Object predecessor(int level) {
int size = stack.size();

if ((size < 2) || (level < 0))
return null;
else
return stack.elementAt(size - (level + 2)); // size - 1 == current
}

/**
* @return current object
*/
public Object current() {
return stack.peek();
}

/**
* @param clazz
* Class to traverse
* @param visitor
* visitor object to apply to all components
*/
public DescendingVisitor(JavaClass clazz, ClassVisitor visitor) {
this.clazz = clazz;
this.visitor = visitor;
}

/**
* Start traversal.
*/
public void visit() {
clazz.accept(this);
}

@Override
public void visitJavaClass(JavaClass clazz) {
stack.push(clazz);
clazz.accept(visitor);

Field[] fields = clazz.getFields();
for (int i = 0; i < fields.length; i++)
fields[i].accept(this);

Method[] methods = clazz.getMethods();
for (int i = 0; i < methods.length; i++)
methods[i].accept(this);

AttributeUtils.accept(clazz.getAttributes(), visitor);
// clazz.getAttributes().accept(this);
clazz.getConstantPool().accept(this);
stack.pop();
}

@Override
public void visitField(Field field) {
stack.push(field);
field.accept(visitor);
AttributeUtils.accept(field.getAttributes(), visitor);
// field.getAttributes().accept(this);
stack.pop();
}

@Override
public void visitConstantValue(ConstantValue cv) {
stack.push(cv);
cv.accept(visitor);
stack.pop();
}

@Override
public void visitMethod(Method method) {
stack.push(method);
method.accept(visitor);
AttributeUtils.accept(method.getAttributes(), visitor);
stack.pop();
}

@Override
public void visitExceptionTable(ExceptionTable table) {
stack.push(table);
table.accept(visitor);
stack.pop();
}

@Override
public void visitCode(Code code) {
stack.push(code);
code.accept(visitor);

CodeException[] table = code.getExceptionTable();
for (int i = 0; i < table.length; i++)
table[i].accept(this);

Attribute[] attributes = code.getAttributes();
for (int i = 0; i < attributes.length; i++)
attributes[i].accept(this);
stack.pop();
}

@Override
public void visitCodeException(CodeException ce) {
stack.push(ce);
ce.accept(visitor);
stack.pop();
}

@Override
public void visitLineNumberTable(LineNumberTable table) {
stack.push(table);
table.accept(visitor);

LineNumber[] numbers = table.getLineNumberTable();
for (int i = 0; i < numbers.length; i++)
numbers[i].accept(this);
stack.pop();
}

@Override
public void visitLineNumber(LineNumber number) {
stack.push(number);
number.accept(visitor);
stack.pop();
}

@Override
public void visitLocalVariableTable(LocalVariableTable table) {
stack.push(table);
table.accept(visitor);

LocalVariable[] vars = table.getLocalVariableTable();
for (int i = 0; i < vars.length; i++)
vars[i].accept(this);
stack.pop();
}

@Override
public void visitStackMap(StackMap table) {
stack.push(table);
table.accept(visitor);

StackMapEntry[] vars = table.getStackMap();

for (int i = 0; i < vars.length; i++)
vars[i].accept(this);
stack.pop();
}

@Override
public void visitStackMapEntry(StackMapEntry var) {
stack.push(var);
var.accept(visitor);
stack.pop();
}

@Override
public void visitLocalVariable(LocalVariable var) {
stack.push(var);
var.accept(visitor);
stack.pop();
}

@Override
public void visitConstantPool(ConstantPool cp) {
stack.push(cp);
cp.accept(visitor);

Constant[] constants = cp.getConstantPool();
for (int i = 1; i < constants.length; i++) {
if (constants[i] != null)
constants[i].accept(this);
}

stack.pop();
}

@Override
public void visitConstantClass(ConstantClass constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantDouble(ConstantDouble constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantFieldref(ConstantFieldref constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantFloat(ConstantFloat constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantInteger(ConstantInteger constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantLong(ConstantLong constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantMethodref(ConstantMethodref constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantMethodHandle(ConstantMethodHandle constant) {
throw new IllegalStateException("nyi");
}

@Override
public void visitConstantMethodType(ConstantMethodType obj) {
throw new IllegalStateException("nyi");
}

@Override
public void visitConstantInvokeDynamic(ConstantInvokeDynamic constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantDynamic(ConstantDynamic obj) {
stack.push(obj);
obj.accept(visitor);
stack.pop();
}

@Override
public void visitBootstrapMethods(BootstrapMethods obj) {
throw new IllegalStateException("nyi");
}

@Override
public void visitConstantNameAndType(ConstantNameAndType constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantString(ConstantString constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantModule(ConstantModule constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantPackage(ConstantPackage constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitConstantUtf8(ConstantUtf8 constant) {
stack.push(constant);
constant.accept(visitor);
stack.pop();
}

@Override
public void visitInnerClasses(InnerClasses ic) {
stack.push(ic);
ic.accept(visitor);

InnerClass[] ics = ic.getInnerClasses();
for (int i = 0; i < ics.length; i++)
ics[i].accept(this);
stack.pop();
}

@Override
public void visitInnerClass(InnerClass inner) {
stack.push(inner);
inner.accept(visitor);
stack.pop();
}

@Override
public void visitDeprecated(Deprecated attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitSignature(Signature attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

// J5SUPPORT:
@Override
public void visitEnclosingMethod(EnclosingMethod attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitRuntimeVisibleAnnotations(RuntimeVisAnnos attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitRuntimeInvisibleAnnotations(RuntimeInvisAnnos attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitRuntimeVisibleParameterAnnotations(RuntimeVisParamAnnos attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisParamAnnos attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitRuntimeVisibleTypeAnnotations(RuntimeVisTypeAnnos attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitMethodParameters(MethodParameters attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisTypeAnnos attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitAnnotationDefault(AnnotationDefault attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitLocalVariableTypeTable(LocalVariableTypeTable table) {
stack.push(table);
table.accept(visitor);

LocalVariable[] vars = table.getLocalVariableTypeTable();
for (int i = 0; i < vars.length; i++)
vars[i].accept(this);
stack.pop();
}

@Override
public void visitSourceFile(SourceFile attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitSynthetic(Synthetic attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitUnknown(Unknown attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitModule(Module attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitModulePackages(ModulePackages attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitModuleMainClass(ModuleMainClass attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitNestHost(NestHost attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}

@Override
public void visitNestMembers(NestMembers attribute) {
stack.push(attribute);
attribute.accept(visitor);
stack.pop();
}
}

+ 0
- 241
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyClassVisitor.java View File

@@ -1,241 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/
package org.aspectj.apache.bcel.verifier;

import org.aspectj.apache.bcel.classfile.AnnotationDefault;
import org.aspectj.apache.bcel.classfile.BootstrapMethods;
import org.aspectj.apache.bcel.classfile.ClassVisitor;
import org.aspectj.apache.bcel.classfile.Code;
import org.aspectj.apache.bcel.classfile.CodeException;
import org.aspectj.apache.bcel.classfile.ConstantClass;
import org.aspectj.apache.bcel.classfile.ConstantDouble;
import org.aspectj.apache.bcel.classfile.ConstantDynamic;
import org.aspectj.apache.bcel.classfile.ConstantFieldref;
import org.aspectj.apache.bcel.classfile.ConstantFloat;
import org.aspectj.apache.bcel.classfile.ConstantInteger;
import org.aspectj.apache.bcel.classfile.ConstantInterfaceMethodref;
import org.aspectj.apache.bcel.classfile.ConstantInvokeDynamic;
import org.aspectj.apache.bcel.classfile.ConstantLong;
import org.aspectj.apache.bcel.classfile.ConstantMethodHandle;
import org.aspectj.apache.bcel.classfile.ConstantMethodType;
import org.aspectj.apache.bcel.classfile.ConstantMethodref;
import org.aspectj.apache.bcel.classfile.ConstantModule;
import org.aspectj.apache.bcel.classfile.ConstantNameAndType;
import org.aspectj.apache.bcel.classfile.ConstantPackage;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.ConstantString;
import org.aspectj.apache.bcel.classfile.ConstantUtf8;
import org.aspectj.apache.bcel.classfile.ConstantValue;
import org.aspectj.apache.bcel.classfile.Deprecated;
import org.aspectj.apache.bcel.classfile.EnclosingMethod;
import org.aspectj.apache.bcel.classfile.ExceptionTable;
import org.aspectj.apache.bcel.classfile.Field;
import org.aspectj.apache.bcel.classfile.InnerClass;
import org.aspectj.apache.bcel.classfile.InnerClasses;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.LineNumber;
import org.aspectj.apache.bcel.classfile.LineNumberTable;
import org.aspectj.apache.bcel.classfile.LocalVariable;
import org.aspectj.apache.bcel.classfile.LocalVariableTable;
import org.aspectj.apache.bcel.classfile.LocalVariableTypeTable;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.MethodParameters;
import org.aspectj.apache.bcel.classfile.Module;
import org.aspectj.apache.bcel.classfile.ModuleMainClass;
import org.aspectj.apache.bcel.classfile.ModulePackages;
import org.aspectj.apache.bcel.classfile.NestHost;
import org.aspectj.apache.bcel.classfile.NestMembers;
import org.aspectj.apache.bcel.classfile.Signature;
import org.aspectj.apache.bcel.classfile.SourceFile;
import org.aspectj.apache.bcel.classfile.StackMap;
import org.aspectj.apache.bcel.classfile.StackMapEntry;
import org.aspectj.apache.bcel.classfile.Synthetic;
import org.aspectj.apache.bcel.classfile.Unknown;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisParamAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisTypeAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisTypeAnnos;

/**
* Visitor with empty method bodies, can be extended and used in conjunction with the
* DescendingVisitor class, e.g.
*
* By courtesy of David Spencer.
*
* @see DescendingVisitor
* @version $Id: EmptyClassVisitor.java,v 1.3 2009/09/15 19:40:22 aclement Exp $
*
*/
public class EmptyClassVisitor implements ClassVisitor {
protected EmptyClassVisitor() { }

@Override
public void visitCode(Code obj) {}
@Override
public void visitCodeException(CodeException obj) {}
@Override
public void visitConstantClass(ConstantClass obj) {}
@Override
public void visitConstantDouble(ConstantDouble obj) {}
@Override
public void visitConstantFieldref(ConstantFieldref obj) {}
@Override
public void visitConstantFloat(ConstantFloat obj) {}
@Override
public void visitConstantInteger(ConstantInteger obj) {}
@Override
public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj) {}
@Override
public void visitConstantLong(ConstantLong obj) {}
@Override
public void visitConstantMethodref(ConstantMethodref obj) {}
@Override
public void visitConstantMethodHandle(ConstantMethodHandle obj) {}
@Override
public void visitConstantMethodType(ConstantMethodType obj) {}
@Override
public void visitConstantInvokeDynamic(ConstantInvokeDynamic obj) {}
@Override
public void visitConstantDynamic(ConstantDynamic obj) {}
@Override
public void visitConstantNameAndType(ConstantNameAndType obj) {}
@Override
public void visitConstantPool(ConstantPool obj) {}
@Override
public void visitConstantString(ConstantString obj) {}
@Override
public void visitConstantModule(ConstantModule obj) {}
@Override
public void visitConstantPackage(ConstantPackage obj) {}
@Override
public void visitConstantUtf8(ConstantUtf8 obj) {}
@Override
public void visitConstantValue(ConstantValue obj) {}
@Override
public void visitDeprecated(Deprecated obj) {}
@Override
public void visitExceptionTable(ExceptionTable obj) {}
@Override
public void visitField(Field obj) {}
@Override
public void visitInnerClass(InnerClass obj) {}
@Override
public void visitInnerClasses(InnerClasses obj) {}
@Override
public void visitJavaClass(JavaClass obj) {}
@Override
public void visitLineNumber(LineNumber obj) {}
@Override
public void visitBootstrapMethods(BootstrapMethods obj) {}
@Override
public void visitLineNumberTable(LineNumberTable obj) {}
@Override
public void visitLocalVariable(LocalVariable obj) {}
@Override
public void visitLocalVariableTable(LocalVariableTable obj) {}
@Override
public void visitMethod(Method obj) {}
@Override
public void visitSignature(Signature obj) {}
@Override
public void visitSourceFile(SourceFile obj) {}
@Override
public void visitSynthetic(Synthetic obj) {}
@Override
public void visitUnknown(Unknown obj) {}
@Override
public void visitStackMap(StackMap obj) {}
@Override
public void visitStackMapEntry(StackMapEntry obj) {}

// J5:
@Override
public void visitEnclosingMethod(EnclosingMethod obj) {}
@Override
public void visitRuntimeVisibleAnnotations(RuntimeVisAnnos attribute) {}
@Override
public void visitRuntimeInvisibleAnnotations(RuntimeInvisAnnos attribute) {}
@Override
public void visitRuntimeVisibleParameterAnnotations(RuntimeVisParamAnnos attribute) {}
@Override
public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisParamAnnos attribute) {}
@Override
public void visitAnnotationDefault(AnnotationDefault attribute) {}
@Override
public void visitLocalVariableTypeTable(LocalVariableTypeTable obj) {}

// J8:
@Override
public void visitRuntimeVisibleTypeAnnotations(RuntimeVisTypeAnnos attribute) {}
@Override
public void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisTypeAnnos attribute) {}
@Override
public void visitMethodParameters(MethodParameters attribute) {}

// J9:
@Override
public void visitModule(Module attribute) {}
@Override
public void visitModulePackages(ModulePackages attribute) {}
@Override
public void visitModuleMainClass(ModuleMainClass attribute) {}

// J11:
@Override public void visitConstantDynamic(ConstantDynamic attribute) {}
@Override public void visitNestHost(NestHost attribute) { }
@Override public void visitNestMembers(NestMembers attribute) { }

}

+ 0
- 259
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyInstVisitor.java View File

@@ -1,259 +0,0 @@
package org.aspectj.apache.bcel.verifier;

import org.aspectj.apache.bcel.generic.FieldInstruction;
import org.aspectj.apache.bcel.generic.IINC;
import org.aspectj.apache.bcel.generic.INVOKEINTERFACE;
import org.aspectj.apache.bcel.generic.InstVisitor;
import org.aspectj.apache.bcel.generic.Instruction;
import org.aspectj.apache.bcel.generic.InstructionBranch;
import org.aspectj.apache.bcel.generic.InstructionLV;
import org.aspectj.apache.bcel.generic.InstructionSelect;
import org.aspectj.apache.bcel.generic.InvokeInstruction;
import org.aspectj.apache.bcel.generic.LOOKUPSWITCH;
import org.aspectj.apache.bcel.generic.MULTIANEWARRAY;
import org.aspectj.apache.bcel.generic.RET;
import org.aspectj.apache.bcel.generic.TABLESWITCH;


/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* Supplies empty method bodies to be overridden by subclasses.
*
* @version $Id: EmptyInstVisitor.java,v 1.2 2008/05/28 23:53:01 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public abstract class EmptyInstVisitor implements InstVisitor {
public void visitStackInstruction(Instruction obj) { }
public void visitLocalVariableInstruction(InstructionLV obj) { }
public void visitBranchInstruction(InstructionBranch obj) { }
public void visitLoadClass(Instruction obj) { }
public void visitFieldInstruction(Instruction obj) { }
public void visitIfInstruction(Instruction obj) { }
public void visitConversionInstruction(Instruction obj) { }
public void visitPopInstruction(Instruction obj) { }
public void visitJsrInstruction(InstructionBranch obj) { }
public void visitGotoInstruction(Instruction obj) { }
public void visitStoreInstruction(Instruction obj) { }
public void visitTypedInstruction(Instruction obj) { }
public void visitSelect(InstructionSelect obj) { }
public void visitUnconditionalBranch(Instruction obj) { }
public void visitPushInstruction(Instruction obj) { }
public void visitArithmeticInstruction(Instruction obj) { }
public void visitCPInstruction(Instruction obj) { }
public void visitInvokeInstruction(InvokeInstruction obj) { }
public void visitArrayInstruction(Instruction obj) { }
public void visitAllocationInstruction(Instruction obj) { }
public void visitReturnInstruction(Instruction obj) { }
public void visitFieldOrMethod(Instruction obj) { }
public void visitConstantPushInstruction(Instruction obj) { }
public void visitExceptionThrower(Instruction obj) { }
public void visitLoadInstruction(Instruction obj) { }
public void visitVariableLengthInstruction(Instruction obj) { }
public void visitStackProducer(Instruction obj) { }
public void visitStackConsumer(Instruction obj) { }
public void visitACONST_NULL(Instruction obj) { }
public void visitGETSTATIC(FieldInstruction obj) { }
public void visitIF_ICMPLT(Instruction obj) { }
public void visitMONITOREXIT(Instruction obj) { }
public void visitIFLT(Instruction obj) { }
public void visitLSTORE(Instruction obj) { }
public void visitPOP2(Instruction obj) { }
public void visitBASTORE(Instruction obj) { }
public void visitISTORE(Instruction obj) { }
public void visitCHECKCAST(Instruction obj) { }
public void visitFCMPG(Instruction obj) { }
public void visitI2F(Instruction obj) { }
public void visitATHROW(Instruction obj) { }
public void visitDCMPL(Instruction obj) { }
public void visitARRAYLENGTH(Instruction obj) { }
public void visitDUP(Instruction obj) { }
public void visitINVOKESTATIC(InvokeInstruction obj) { }
public void visitLCONST(Instruction obj) { }
public void visitDREM(Instruction obj) { }
public void visitIFGE(Instruction obj) { }
public void visitCALOAD(Instruction obj) { }
public void visitLASTORE(Instruction obj) { }
public void visitI2D(Instruction obj) { }
public void visitDADD(Instruction obj) { }
public void visitINVOKESPECIAL(InvokeInstruction obj) { }
public void visitIAND(Instruction obj) { }
public void visitPUTFIELD(FieldInstruction obj) { }
public void visitILOAD(Instruction obj) { }
public void visitDLOAD(Instruction obj) { }
public void visitDCONST(Instruction obj) { }
public void visitNEW(Instruction obj) { }
public void visitIFNULL(Instruction obj) { }
public void visitLSUB(Instruction obj) { }
public void visitL2I(Instruction obj) { }
public void visitISHR(Instruction obj) { }
public void visitTABLESWITCH(TABLESWITCH obj) { }
public void visitIINC(IINC obj) { }
public void visitDRETURN(Instruction obj) { }
public void visitFSTORE(Instruction obj) { }
public void visitDASTORE(Instruction obj) { }
public void visitIALOAD(Instruction obj) { }
public void visitDDIV(Instruction obj) { }
public void visitIF_ICMPGE(Instruction obj) { }
public void visitLAND(Instruction obj) { }
public void visitIDIV(Instruction obj) { }
public void visitLOR(Instruction obj) { }
public void visitCASTORE(Instruction obj) { }
public void visitFREM(Instruction obj) { }
public void visitLDC(Instruction obj) { }
public void visitBIPUSH(Instruction obj) { }
public void visitDSTORE(Instruction obj) { }
public void visitF2L(Instruction obj) { }
public void visitFMUL(Instruction obj) { }
public void visitLLOAD(Instruction obj) { }
public void visitJSR(InstructionBranch obj) { }
public void visitFSUB(Instruction obj) { }
public void visitSASTORE(Instruction obj) { }
public void visitALOAD(Instruction obj) { }
public void visitDUP2_X2(Instruction obj) { }
public void visitRETURN(Instruction obj) { }
public void visitDALOAD(Instruction obj) { }
public void visitSIPUSH(Instruction obj) { }
public void visitDSUB(Instruction obj) { }
public void visitL2F(Instruction obj) { }
public void visitIF_ICMPGT(Instruction obj) { }
public void visitF2D(Instruction obj) { }
public void visitI2L(Instruction obj) { }
public void visitIF_ACMPNE(Instruction obj) { }
public void visitPOP(Instruction obj) { }
public void visitI2S(Instruction obj) { }
public void visitIFEQ(Instruction obj) { }
public void visitSWAP(Instruction obj) { }
public void visitIOR(Instruction obj) { }
public void visitIREM(Instruction obj) { }
public void visitIASTORE(Instruction obj) { }
public void visitNEWARRAY(Instruction obj) { }
public void visitINVOKEINTERFACE(INVOKEINTERFACE obj) { }
public void visitINEG(Instruction obj) { }
public void visitLCMP(Instruction obj) { }
public void visitJSR_W(InstructionBranch obj) { }
public void visitMULTIANEWARRAY(MULTIANEWARRAY obj) { }
public void visitDUP_X2(Instruction obj) { }
public void visitSALOAD(Instruction obj) { }
public void visitIFNONNULL(Instruction obj) { }
public void visitDMUL(Instruction obj) { }
public void visitIFNE(Instruction obj) { }
public void visitIF_ICMPLE(Instruction obj) { }
public void visitLDC2_W(Instruction obj) { }
public void visitGETFIELD(FieldInstruction obj) { }
public void visitLADD(Instruction obj) { }
public void visitNOP(Instruction obj) { }
public void visitFALOAD(Instruction obj) { }
public void visitINSTANCEOF(Instruction obj) { }
public void visitIFLE(Instruction obj) { }
public void visitLXOR(Instruction obj) { }
public void visitLRETURN(Instruction obj) { }
public void visitFCONST(Instruction obj) { }
public void visitIUSHR(Instruction obj) { }
public void visitBALOAD(Instruction obj) { }
public void visitDUP2(Instruction obj) { }
public void visitIF_ACMPEQ(Instruction obj) { }
public void visitIMPDEP1(Instruction obj) { }
public void visitMONITORENTER(Instruction obj) { }
public void visitLSHL(Instruction obj) { }
public void visitDCMPG(Instruction obj) { }
public void visitD2L(Instruction obj) { }
public void visitIMPDEP2(Instruction obj) { }
public void visitL2D(Instruction obj) { }
public void visitRET(RET obj) { }
public void visitIFGT(Instruction obj) { }
public void visitIXOR(Instruction obj) { }
public void visitINVOKEVIRTUAL(InvokeInstruction obj) { }
public void visitFASTORE(Instruction obj) { }
public void visitIRETURN(Instruction obj) { }
public void visitIF_ICMPNE(Instruction obj) { }
public void visitFLOAD(Instruction obj) { }
public void visitLDIV(Instruction obj) { }
public void visitPUTSTATIC(FieldInstruction obj) { }
public void visitAALOAD(Instruction obj) { }
public void visitD2I(Instruction obj) { }
public void visitIF_ICMPEQ(Instruction obj) { }
public void visitAASTORE(Instruction obj) { }
public void visitARETURN(Instruction obj) { }
public void visitDUP2_X1(Instruction obj) { }
public void visitFNEG(Instruction obj) { }
public void visitGOTO_W(Instruction obj) { }
public void visitD2F(Instruction obj) { }
public void visitGOTO(Instruction obj) { }
public void visitISUB(Instruction obj) { }
public void visitF2I(Instruction obj) { }
public void visitDNEG(Instruction obj) { }
public void visitICONST(Instruction obj) { }
public void visitFDIV(Instruction obj) { }
public void visitI2B(Instruction obj) { }
public void visitLNEG(Instruction obj) { }
public void visitLREM(Instruction obj) { }
public void visitIMUL(Instruction obj) { }
public void visitIADD(Instruction obj) { }
public void visitLSHR(Instruction obj) { }
public void visitLOOKUPSWITCH(LOOKUPSWITCH obj) { }
public void visitDUP_X1(Instruction obj) { }
public void visitFCMPL(Instruction obj) { }
public void visitI2C(Instruction obj) { }
public void visitLMUL(Instruction obj) { }
public void visitLUSHR(Instruction obj) { }
public void visitISHL(Instruction obj) { }
public void visitLALOAD(Instruction obj) { }
public void visitASTORE(Instruction obj) { }
public void visitANEWARRAY(Instruction obj) { }
public void visitFRETURN(Instruction obj) { }
public void visitFADD(Instruction obj) { }
public void visitBREAKPOINT(Instruction obj) { }
}

+ 0
- 111
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/GraphicalVerifier.java View File

@@ -1,111 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.UIManager;

import org.aspectj.apache.bcel.generic.Type;


/**
* A graphical user interface application demonstrating JustIce.
*
* @version $Id: GraphicalVerifier.java,v 1.2 2008/05/28 23:53:01 aclement Exp $
* @author Enver Haase
*/
public class GraphicalVerifier {
boolean packFrame = false;

/** Constructor. */
public GraphicalVerifier() {
VerifierAppFrame frame = new VerifierAppFrame();
//Frames �berpr�fen, die voreingestellte Gr��e haben
//Frames packen, die nutzbare bevorzugte Gr��eninformationen enthalten, z.B. aus ihrem Layout
if (packFrame) {
frame.pack();
}
else {
frame.validate();
}
//Das Fenster zentrieren
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);

frame.classNamesJList.setModel(new VerifierFactoryListModel());
VerifierFactory.getVerifier(Type.OBJECT.getClassName()); // Fill list with java.lang.Object
frame.classNamesJList.setSelectedIndex(0); // default, will verify java.lang.Object
}
/** Main method. */
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
new GraphicalVerifier();
}
}

+ 0
- 459
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/InstructionWalker.java View File

@@ -1,459 +0,0 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, i list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, i list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "i product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, i acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from i software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from i software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* i SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF i SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* i software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/
package org.aspectj.apache.bcel.verifier;

import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.generic.FieldInstruction;
import org.aspectj.apache.bcel.generic.InstVisitor;
import org.aspectj.apache.bcel.generic.Instruction;
import org.aspectj.apache.bcel.generic.InstructionBranch;
import org.aspectj.apache.bcel.generic.InstructionLV;
import org.aspectj.apache.bcel.generic.InvokeInstruction;

/**
* Traverse an instruction
*
* @author Andy Clement
*/
public class InstructionWalker implements Constants {

/**
* Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call methods
* according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.
*
* @param i the instruction to visit
* @param v Visitor object
*/
public static void accept(Instruction i, InstVisitor v) {
switch (i.opcode) {
case IMPDEP1:
v.visitIMPDEP1(i);
break;
case IMPDEP2:
v.visitIMPDEP2(i);
break;
case MONITORENTER:
v.visitExceptionThrower(i);
v.visitStackConsumer(i);
v.visitMONITORENTER(i);
break;
case MONITOREXIT:
v.visitExceptionThrower(i);
v.visitStackConsumer(i);
v.visitMONITOREXIT(i);
break;
case LCMP:
v.visitTypedInstruction(i);
v.visitStackProducer(i);
v.visitStackConsumer(i);
v.visitLCMP(i);
break;
case FCMPL:
v.visitTypedInstruction(i);
v.visitStackProducer(i);
v.visitStackConsumer(i);
v.visitFCMPL(i);
break;
case FCMPG:
v.visitTypedInstruction(i);
v.visitStackProducer(i);
v.visitStackConsumer(i);
v.visitFCMPG(i);
break;
case DCMPL:
v.visitTypedInstruction(i);
v.visitStackProducer(i);
v.visitStackConsumer(i);
v.visitDCMPL(i);
break;
case DCMPG:
v.visitTypedInstruction(i);
v.visitStackProducer(i);
v.visitStackConsumer(i);
v.visitDCMPG(i);
break;
case NOP:
v.visitNOP(i);
break;
case BREAKPOINT:
v.visitBREAKPOINT(i);
break;
case SWAP:
v.visitStackConsumer(i);
v.visitStackProducer(i);
v.visitStackInstruction(i);
v.visitSWAP(i);
break;
case POP:
v.visitStackConsumer(i);
v.visitPopInstruction(i);
v.visitStackInstruction(i);
v.visitPOP(i);
break;
case POP2:
v.visitStackConsumer(i);
v.visitPopInstruction(i);
v.visitStackInstruction(i);
v.visitPOP2(i);
break;
case DUP2_X1:
v.visitStackInstruction(i);
v.visitDUP2_X1(i);
break;
case DUP2_X2:
v.visitStackInstruction(i);
v.visitDUP2_X2(i);
break;
case DUP2:
v.visitStackProducer(i);
v.visitPushInstruction(i);
v.visitStackInstruction(i);
v.visitDUP2(i);
break;
case DUP_X1:
v.visitStackInstruction(i);
v.visitDUP_X1(i);
break;
case DUP_X2:
v.visitStackInstruction(i);
v.visitDUP_X2(i);
break;
case DUP:
v.visitStackProducer(i);
v.visitPushInstruction(i);
v.visitStackInstruction(i);
v.visitDUP(i);
break;
case BASTORE:
v.visitStackConsumer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitBASTORE(i);
break;
case CASTORE:
v.visitStackConsumer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitCASTORE(i);
break;
case SASTORE:
v.visitStackConsumer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitSASTORE(i);
break;
case DASTORE:
v.visitStackConsumer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitDASTORE(i);
break;
case FASTORE:
v.visitStackConsumer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitFASTORE(i);
break;
case LASTORE:
v.visitStackConsumer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitLASTORE(i);
break;
case IASTORE:
v.visitStackConsumer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitIASTORE(i);
break;
case AASTORE:
v.visitStackConsumer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitAASTORE(i);
break;
case SALOAD:
v.visitStackProducer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitSALOAD(i);
break;
case CALOAD:
v.visitStackProducer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitCALOAD(i);
break;
case DALOAD:
v.visitStackProducer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitDALOAD(i);
break;
case FALOAD:
v.visitStackProducer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitFALOAD(i);
break;
case LALOAD:
v.visitStackProducer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitLALOAD(i);
break;
case AALOAD:
v.visitStackProducer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitAALOAD(i);
break;
case ATHROW:
v.visitUnconditionalBranch(i);
v.visitExceptionThrower(i);
v.visitATHROW(i);
break;
case ACONST_NULL:
v.visitStackProducer(i);
v.visitPushInstruction(i);
v.visitTypedInstruction(i);
v.visitACONST_NULL(i);
break;
case ICONST_M1:
case ICONST_0:
case ICONST_1:
case ICONST_2:
case ICONST_3:
case ICONST_4:
case ICONST_5:
v.visitPushInstruction(i);
v.visitStackProducer(i);
v.visitTypedInstruction(i);
v.visitConstantPushInstruction(i);
v.visitICONST(i);
break;
case LCONST_0:
case LCONST_1:
v.visitPushInstruction(i);
v.visitStackProducer(i);
v.visitTypedInstruction(i);
v.visitConstantPushInstruction(i);
v.visitLCONST(i);
break;
case FCONST_0:
case FCONST_1:
case FCONST_2:
v.visitPushInstruction(i);
v.visitStackProducer(i);
v.visitTypedInstruction(i);
v.visitConstantPushInstruction(i);
v.visitFCONST(i);
break;
case DCONST_0:
case DCONST_1:
v.visitPushInstruction(i);
v.visitStackProducer(i);
v.visitTypedInstruction(i);
v.visitConstantPushInstruction(i);
v.visitDCONST(i);
break;
case BALOAD:
v.visitStackProducer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitBALOAD(i);
break;
case IALOAD:
v.visitStackProducer(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitArrayInstruction(i);
v.visitIALOAD(i);
break;
case BIPUSH:
v.visitPushInstruction(i);
v.visitStackProducer(i);
v.visitTypedInstruction(i);
v.visitConstantPushInstruction(i);
v.visitBIPUSH(i);
break;
case SIPUSH:
v.visitPushInstruction(i);
v.visitStackProducer(i);
v.visitTypedInstruction(i);
v.visitConstantPushInstruction(i);
v.visitSIPUSH(i);
break;
case LDC:
case LDC_W:
v.visitStackProducer(i);
v.visitPushInstruction(i);
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitCPInstruction(i);
v.visitLDC(i);
break;
case LDC2_W:
v.visitStackProducer(i);
v.visitPushInstruction(i);
v.visitTypedInstruction(i);
v.visitCPInstruction(i);
v.visitLDC2_W(i);
break;
case ARRAYLENGTH:
v.visitExceptionThrower(i);
v.visitStackProducer(i);
v.visitARRAYLENGTH(i);
break;
case ASTORE_0:
v.visitStackConsumer(i);
v.visitPopInstruction(i);
v.visitStoreInstruction(i);
v.visitTypedInstruction(i);
v.visitLocalVariableInstruction((InstructionLV) i);
v.visitStoreInstruction(i);
v.visitASTORE(i);
break;
case ALOAD_0:
v.visitStackConsumer(i);
v.visitPopInstruction(i);
v.visitStoreInstruction(i);
v.visitTypedInstruction(i);
v.visitLocalVariableInstruction((InstructionLV) i);
v.visitStoreInstruction(i);
v.visitALOAD(i);
break;
// for store instructions: ISTORE > ASTORE_3 - needs to visit the instruction too
// v.visitStackConsumer(i);
// v.visitPopInstruction(i);
// v.visitStoreInstruction(i);
// v.visitTypedInstruction(i);
// v.visitLocalVariableInstruction(i);
// v.visitStoreInstruction(i);
// for load instructions: ILOAD > ALOAD_3 - needs to visit the instruction too
// v.visitStackProducer(i);
// v.visitPushInstruction(i);
// v.visitTypedInstruction(i);
// v.visitLocalVariableInstruction(i);
// v.visitLoadInstruction(i);

// for conversion instructions: (all 15 of them) - needs to visit conversion instruction too
// v.visitTypedInstruction(i);
// v.visitStackProducer(i);
// v.visitStackConsumer(i);
// v.visitConversionInstruction(i);

// arithmetic instructions - need to visit the instructions too (iadd etc)
// v.visitTypedInstruction(i);
// v.visitStackProducer(i);
// v.visitStackConsumer(i);
// v.visitArithmeticInstruction(i);

case INVOKESTATIC:
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitStackConsumer(i);
v.visitStackProducer(i);
v.visitLoadClass(i);
v.visitCPInstruction(i);
v.visitFieldOrMethod(i);
v.visitInvokeInstruction((InvokeInstruction) i);
v.visitINVOKESTATIC((InvokeInstruction) i);
break;

case GOTO:
v.visitVariableLengthInstruction(i);
v.visitUnconditionalBranch(i);
v.visitBranchInstruction((InstructionBranch) i);
v.visitGotoInstruction(i);
v.visitGOTO(i);
break;
case PUTSTATIC:
v.visitExceptionThrower(i);
v.visitStackConsumer(i);
v.visitPopInstruction(i);
v.visitTypedInstruction(i);
v.visitLoadClass(i);
v.visitCPInstruction(i);
v.visitFieldOrMethod(i);
v.visitFieldInstruction(i);
v.visitPUTSTATIC((FieldInstruction) i);
break;
case RETURN:
v.visitExceptionThrower(i);
v.visitTypedInstruction(i);
v.visitStackConsumer(i);
v.visitReturnInstruction(i);
v.visitRETURN(i);
break;
default:
throw new IllegalStateException("visiting not yet implemented for " + i.getName().toUpperCase());
}
}
}

+ 0
- 116
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/NativeVerifier.java View File

@@ -1,116 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* The NativeVerifier class implements a main(String[] args) method that's
* roughly compatible to the one in the Verifier class, but that uses the
* JVM's internal verifier for its class file verification.
* This can be used for comparison runs between the JVM-internal verifier
* and JustIce.
*
* @version $Id: NativeVerifier.java,v 1.2 2008/05/28 23:53:01 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public abstract class NativeVerifier{

/**
* This class must not be instantiated.
*/
private NativeVerifier(){
}

/**
* Works only on the first argument.
*/
public static void main(String [] args){
if (args.length != 1){
System.out.println("Verifier front-end: need exactly one argument.");
System.exit(1);
}

int dotclasspos = args[0].lastIndexOf(".class");
if (dotclasspos != -1) args[0] = args[0].substring(0,dotclasspos);
args[0] = args[0].replace('/','.');
//System.out.println(args[0]);


try{
Class.forName(args[0]);
}
catch(ExceptionInInitializerError eiie){ //subclass of LinkageError!
System.out.println("NativeVerifier: ExceptionInInitializerError encountered on '"+args[0]+"'.");
System.out.println(eiie);
System.exit(1);
}
catch(LinkageError le){
System.out.println("NativeVerifier: LinkageError encountered on '"+args[0]+"'.");
System.out.println(le);
System.exit(1);
}
catch(ClassNotFoundException cnfe){
System.out.println("NativeVerifier: FILE NOT FOUND: '"+args[0]+"'.");
System.exit(1);
}
catch(Throwable t){
System.out.println("NativeVerifier: Unspecified verification error on'"+args[0]+"'.");
System.exit(1);
}

System.out.println("NativeVerifier: Class file '"+args[0]+"' seems to be okay.");
System.exit(0);

}
}

+ 0
- 143
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/PassVerifier.java View File

@@ -1,143 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.util.ArrayList;

/**
* A PassVerifier actually verifies a class file; it is instantiated
* by a Verifier.
* The verification should conform with a certain pass as described
* in The Java Virtual Machine Specification, 2nd edition.
* This book describes four passes. Pass one means loading the
* class and verifying a few static constraints. Pass two actually
* verifies some other constraints that could enforce loading in
* referenced class files. Pass three is the first pass that actually
* checks constraints in the code array of a method in the class file;
* it has two parts with the first verifying static constraints and
* the second part verifying structural constraints (where a data flow
* analysis is used for). The fourth pass, finally, performs checks
* that can only be done at run-time.
* JustIce does not have a run-time pass, but certain constraints that
* are usually delayed until run-time for performance reasons are also
* checked during the second part of pass three.
* PassVerifier instances perform caching.
* That means, if you really want a new verification run of a certain
* pass you must use a new instance of a given PassVerifier.
*
* @version $Id: PassVerifier.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see org.aspectj.apache.bcel.verifier.Verifier
* @see #verify()
*/
public abstract class PassVerifier{

/** The (warning) messages. */
private ArrayList<String> messages = new ArrayList<String>(); //Type of elements: String

/** The VerificationResult cache. */
private VerificationResult verificationResult = null;

/**
* This method runs a verification pass conforming to the
* Java Virtual Machine Specification, 2nd edition, on a
* class file.
* PassVerifier instances perform caching;
* i.e. if the verify() method once determined a VerificationResult,
* then this result may be returned after every invocation of this
* method instead of running the verification pass anew; likewise with
* the result of getMessages().
*
* @see #getMessages()
* @see #addMessage(String)
*/
public VerificationResult verify(){
if (verificationResult == null){
verificationResult = do_verify();
}
return verificationResult;
}

/** Does the real verification work, uncached. */
public abstract VerificationResult do_verify();

/**
* This method adds a (warning) message to the message pool of this
* PassVerifier. This method is normally only internally used by
* BCEL's class file verifier "JustIce" and should not be used from
* the outside.
*
* @see #getMessages()
*/
public void addMessage(String message){
messages.add(message);
}

/**
* Returns the (warning) messages that this PassVerifier accumulated
* during its do_verify()ing work.
*
* @see #addMessage(String)
* @see #do_verify()
*/
public String[] getMessages(){
verify(); // create messages if not already done (cached!)
String[] ret = new String[messages.size()];
for (int i=0; i<messages.size(); i++){
ret[i] = messages.get(i);
}
return ret;
}
}

+ 0
- 137
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/TransitiveHull.java View File

@@ -1,137 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.Repository;
import org.aspectj.apache.bcel.classfile.JavaClass;

/**
* This class has a main method implementing a demonstration program
* of how to use the VerifierFactoryObserver. It transitively verifies
* all class files encountered; this may take up a lot of time and,
* more notably, memory.
*
* @version $Id: TransitiveHull.java,v 1.2 2008/05/28 23:53:00 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class TransitiveHull implements VerifierFactoryObserver{

/** Used for indentation. */
private int indent = 0;

/** Not publicly instantiable. */
private TransitiveHull(){
}

/* Implementing VerifierFactoryObserver. */
public void update(String classname){

System.gc(); // avoid swapping if possible.

for (int i=0; i<indent; i++){
System.out.print(" ");
}
System.out.println(classname);
indent += 1;

Verifier v = VerifierFactory.getVerifier(classname);

VerificationResult vr;
vr = v.doPass1();
if (vr != VerificationResult.VR_OK) //System.exit(1);
System.out.println("Pass 1:\n"+vr);

vr = v.doPass2();
if (vr != VerificationResult.VR_OK) //System.exit(1);
System.out.println("Pass 2:\n"+vr);

if (vr == VerificationResult.VR_OK){
JavaClass jc = Repository.lookupClass(v.getClassName());
for (int i=0; i<jc.getMethods().length; i++){
vr = v.doPass3a(i);
if (vr != VerificationResult.VR_OK) //System.exit(1);
System.out.println(v.getClassName()+", Pass 3a, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);

vr = v.doPass3b(i);
if (vr != VerificationResult.VR_OK) //System.exit(1);
System.out.println(v.getClassName()+", Pass 3b, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
}
}

indent -= 1;
}

/**
* This method implements a demonstration program
* of how to use the VerifierFactoryObserver. It transitively verifies
* all class files encountered; this may take up a lot of time and,
* more notably, memory.
*/
public static void main(String[] args){
if (args.length != 1){
System.out.println("Need exactly one argument: The root class to verify.");
System.exit(1);
}

int dotclasspos = args[0].lastIndexOf(".class");
if (dotclasspos != -1) args[0] = args[0].substring(0,dotclasspos);
args[0] = args[0].replace('/', '.');

TransitiveHull th = new TransitiveHull();
VerifierFactory.attach(th);
VerifierFactory.getVerifier(args[0]); // the observer is called back and does the actual trick.
VerifierFactory.detach(th);
}
}

+ 0
- 135
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerificationResult.java View File

@@ -1,135 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* A VerificationResult is what a PassVerifier returns
* after verifying.
*
* @version $Id: VerificationResult.java,v 1.2 2008/05/28 23:53:00 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*
*/
public class VerificationResult{

/**
* Constant to indicate verification has not been tried yet.
* This happens if some earlier verification pass did not return VERIFIED_OK.
*/
public static final int VERIFIED_NOTYET = 0;
/** Constant to indicate verification was passed. */
public static final int VERIFIED_OK = 1;
/** Constant to indicate verfication failed. */
public static final int VERIFIED_REJECTED = 2;

/**
* This string is the canonical message for verifications that have not been tried yet.
* This happens if some earlier verification pass did not return VERIFIED_OK.
*/
private static final String VERIFIED_NOTYET_MSG = "Not yet verified.";
/** This string is the canonical message for passed verification passes. */
private static final String VERIFIED_OK_MSG = "Passed verification.";

/**
* Canonical VerificationResult for not-yet-tried verifications.
* This happens if some earlier verification pass did not return VERIFIED_OK.
*/
public static final VerificationResult VR_NOTYET = new VerificationResult(VERIFIED_NOTYET, VERIFIED_NOTYET_MSG);
/** Canonical VerificationResult for passed verifications. */
public static final VerificationResult VR_OK = new VerificationResult(VERIFIED_OK, VERIFIED_OK_MSG);

/** The numeric status. */
private int numeric;

/** The detailed message. */
private String detailMessage;

/** The usual constructor. */
public VerificationResult(int status, String message){
numeric = status;
detailMessage = message;
}

/** Returns one one the VERIFIED_OK, VERIFIED_NOTYET, VERIFIED_REJECTED constants. */
public int getStatus(){
return numeric;
}

/** Returns a detailed message. */
public String getMessage(){
return detailMessage;
}

/**
* Returns if two VerificationResult instances are equal.
*/
public boolean equals(Object o){
if (! (o instanceof VerificationResult)) return false;
VerificationResult other = (VerificationResult) o;
return ((other.numeric == this.numeric) && (other.detailMessage.equals(this.detailMessage)));
}

/**
* Returns a String representation of the VerificationResult.
*/
public String toString(){
String ret="";
if (numeric == VERIFIED_NOTYET) ret = "VERIFIED_NOTYET";
if (numeric == VERIFIED_OK) ret = "VERIFIED_OK";
if (numeric == VERIFIED_REJECTED) ret = "VERIFIED_REJECTED";
ret+="\n"+detailMessage+"\n";
return ret;
}
}

+ 0
- 288
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/Verifier.java View File

@@ -1,288 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.verifier.statics.Pass1Verifier;
import org.aspectj.apache.bcel.verifier.statics.Pass2Verifier;
import org.aspectj.apache.bcel.verifier.statics.Pass3aVerifier;
import org.aspectj.apache.bcel.verifier.structurals.Pass3bVerifier;

/**
* A Verifier instance is there to verify a class file according to The Java Virtual
* Machine Specification, 2nd Edition.
*
* Pass-3b-verification includes pass-3a-verification;
* pass-3a-verification includes pass-2-verification;
* pass-2-verification includes pass-1-verification.
*
* A Verifier creates PassVerifier instances to perform the actual verification.
* Verifier instances are usually generated by the VerifierFactory.
*
* @version $Id: Verifier.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see org.aspectj.apache.bcel.verifier.VerifierFactory
* @see org.aspectj.apache.bcel.verifier.PassVerifier
*/
public class Verifier{
/**
* The name of the class this verifier operates on.
*/
private final String classname;

/** A Pass1Verifier for this Verifier instance. */
private Pass1Verifier p1v;
/** A Pass2Verifier for this Verifier instance. */
private Pass2Verifier p2v;
/** The Pass3aVerifiers for this Verifier instance. Key: Interned string specifying the method number. */
private HashMap<String, Pass3aVerifier> p3avs = new HashMap<String, Pass3aVerifier>();
/** The Pass3bVerifiers for this Verifier instance. Key: Interned string specifying the method number. */
private HashMap<String, Pass3bVerifier> p3bvs = new HashMap<String, Pass3bVerifier>();

/** Returns the VerificationResult for the given pass. */
public VerificationResult doPass1(){
if (p1v == null){
p1v = new Pass1Verifier(this);
}
return p1v.verify();
}

/** Returns the VerificationResult for the given pass. */
public VerificationResult doPass2(){
if (p2v == null){
p2v = new Pass2Verifier(this);
}
return p2v.verify();
}

/** Returns the VerificationResult for the given pass. */
public VerificationResult doPass3a(int method_no){
String key = Integer.toString(method_no);
Pass3aVerifier p3av;
p3av = (p3avs.get(key));
if (p3avs.get(key) == null){
p3av = new Pass3aVerifier(this, method_no);
p3avs.put(key, p3av);
}
return p3av.verify();
}

/** Returns the VerificationResult for the given pass. */
public VerificationResult doPass3b(int method_no){
String key = Integer.toString(method_no);
Pass3bVerifier p3bv;
p3bv = (p3bvs.get(key));
if (p3bvs.get(key) == null){
p3bv = new Pass3bVerifier(this, method_no);
p3bvs.put(key, p3bv);
}
return p3bv.verify();
}


/**
* Instantiation is done by the VerifierFactory.
*
* @see VerifierFactory
*/
Verifier(String fully_qualified_classname){
classname = fully_qualified_classname;
flush();
}

/**
* Returns the name of the class this verifier operates on.
* This is particularly interesting when this verifier was created
* recursively by another Verifier and you got a reference to this
* Verifier by the getVerifiers() method of the VerifierFactory.
* @see VerifierFactory
*/
public final String getClassName(){
return classname;
}

/**
* Forget everything known about the class file; that means, really
* start a new verification of a possibly different class file from
* BCEL's repository.
*
*/
public void flush(){
p1v = null;
p2v = null;
p3avs.clear();
p3bvs.clear();
}

/**
* This returns all the (warning) messages collected during verification.
* A prefix shows from which verifying pass a message originates.
*/
public String[] getMessages(){
ArrayList messages = new ArrayList();

if (p1v != null){
String[] p1m = p1v.getMessages();
for (int i=0; i<p1m.length; i++){
messages.add("Pass 1: "+p1m[i]);
}
}
if (p2v != null){
String[] p2m = p2v.getMessages();
for (int i=0; i<p2m.length; i++){
messages.add("Pass 2: "+p2m[i]);
}
}
Iterator<Pass3aVerifier> p3as = p3avs.values().iterator();
while (p3as.hasNext()){
Pass3aVerifier pv = p3as.next();
String[] p3am = pv.getMessages();
int meth = pv.getMethodNo();
for (int i=0; i<p3am.length; i++){
messages.add("Pass 3a, method "+meth+
" ('"+
org.aspectj.apache.bcel.Repository
.lookupClass(classname)
.getMethods()[meth] +
"'): "+p3am[i]);
}
}
Iterator<Pass3bVerifier> p3bs = p3bvs.values().iterator();
while (p3bs.hasNext()){
Pass3bVerifier pv = p3bs.next();
String[] p3bm = pv.getMessages();
int meth = pv.getMethodNo();
for (int i=0; i<p3bm.length; i++){
messages.add("Pass 3b, method "+meth+
" ('"+
org.aspectj.apache.bcel.Repository.
lookupClass(classname).
getMethods()[meth] +
"'): "+p3bm[i]);
}
}

String[] ret = new String[messages.size()];
for (int i=0; i< messages.size(); i++){
ret[i] = (String) messages.get(i);
}

return ret;
}

/**
* Verifies class files.
* This is a simple demonstration of how the API of BCEL's
* class file verifier "JustIce" may be used.
* You should supply command-line arguments which are
* fully qualified namea of the classes to verify. These class files
* must be somewhere in your CLASSPATH (refer to Sun's
* documentation for questions about this) or you must have put the classes
* into the BCEL Repository yourself (via 'addClass(JavaClass)').
*/
public static void main(String [] args){
System.out.println("JustIce by Enver Haase, (C) 2001-2002.\n<https://bcel.sourceforge.net>\n<https://jakarta.apache.org/bcel>\n");
for(int k=0; k < args.length; k++) {

if (args[k].endsWith(".class")){
int dotclasspos = args[k].lastIndexOf(".class");
if (dotclasspos != -1) args[k] = args[k].substring(0,dotclasspos);
}

args[k] = args[k].replace('/', '.');

System.out.println("Now verifying: "+args[k]+"\n");

Verifier v = VerifierFactory.getVerifier(args[k]);
VerificationResult vr;

vr = v.doPass1();
System.out.println("Pass 1:\n"+vr);

vr = v.doPass2();
System.out.println("Pass 2:\n"+vr);

if (vr == VerificationResult.VR_OK){
JavaClass jc = org.aspectj.apache.bcel.Repository
.lookupClass(args[k]);
for (int i=0; i<jc.getMethods().length; i++){
vr = v.doPass3a(i);
System.out.println("Pass 3a, method number "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);

vr = v.doPass3b(i);
System.out.println("Pass 3b, method number "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
}
}

System.out.println("Warnings:");
String[] warnings = v.getMessages();
if (warnings.length == 0) System.out.println("<none>");
for (int j=0; j<warnings.length; j++){
System.out.println(warnings[j]);
}

System.out.println("\n");

// avoid swapping.
v.flush();
org.aspectj.apache.bcel.Repository.clearCache();
System.gc();
}
}
}

+ 0
- 409
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierAppFrame.java View File

@@ -1,409 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.awt.AWTEvent;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextPane;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;

import org.aspectj.apache.bcel.Repository;
import org.aspectj.apache.bcel.classfile.JavaClass;

/**
* This class implements a machine-generated frame for use with
* the GraphicalVerfifier.
*
* @version $Id: VerifierAppFrame.java,v 1.2 2008/05/28 23:53:01 aclement Exp $
* @author Enver Haase
* @see GraphicalVerifier
*/
public class VerifierAppFrame extends JFrame {
JPanel contentPane;
JSplitPane jSplitPane1 = new JSplitPane();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JSplitPane jSplitPane2 = new JSplitPane();
JPanel jPanel3 = new JPanel();
JList classNamesJList = new JList();
GridLayout gridLayout1 = new GridLayout();
JPanel messagesPanel = new JPanel();
GridLayout gridLayout2 = new GridLayout();
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenu1 = new JMenu();
JScrollPane jScrollPane1 = new JScrollPane();
JScrollPane messagesScrollPane = new JScrollPane();
JScrollPane jScrollPane3 = new JScrollPane();
GridLayout gridLayout4 = new GridLayout();
JScrollPane jScrollPane4 = new JScrollPane();
CardLayout cardLayout1 = new CardLayout();

private String JUSTICE_VERSION = "JustIce by Enver Haase";
private String current_class;
GridLayout gridLayout3 = new GridLayout();
JTextPane pass1TextPane = new JTextPane();
JTextPane pass2TextPane = new JTextPane();
JTextPane messagesTextPane = new JTextPane();
JMenuItem newFileMenuItem = new JMenuItem();
JSplitPane jSplitPane3 = new JSplitPane();
JSplitPane jSplitPane4 = new JSplitPane();
JScrollPane jScrollPane2 = new JScrollPane();
JScrollPane jScrollPane5 = new JScrollPane();
JScrollPane jScrollPane6 = new JScrollPane();
JScrollPane jScrollPane7 = new JScrollPane();
JList pass3aJList = new JList();
JList pass3bJList = new JList();
JTextPane pass3aTextPane = new JTextPane();
JTextPane pass3bTextPane = new JTextPane();
JMenu jMenu2 = new JMenu();
JMenuItem whatisMenuItem = new JMenuItem();
JMenuItem aboutMenuItem = new JMenuItem();

/** Constructor. */
public VerifierAppFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/** Initizalization of the components. */
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Ihr Symbol]")));
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(cardLayout1);
this.setJMenuBar(jMenuBar1);
this.setSize(new Dimension(708, 451));
this.setTitle("JustIce");
jPanel1.setMinimumSize(new Dimension(100, 100));
jPanel1.setPreferredSize(new Dimension(100, 100));
jPanel1.setLayout(gridLayout1);
jSplitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT);
jPanel2.setLayout(gridLayout2);
jPanel3.setMinimumSize(new Dimension(200, 100));
jPanel3.setPreferredSize(new Dimension(400, 400));
jPanel3.setLayout(gridLayout4);
messagesPanel.setMinimumSize(new Dimension(100, 100));
messagesPanel.setLayout(gridLayout3);
jPanel2.setMinimumSize(new Dimension(200, 100));
jMenu1.setText("File");

jScrollPane1.getViewport().setBackground(Color.red);
messagesScrollPane.getViewport().setBackground(Color.red);
messagesScrollPane.setPreferredSize(new Dimension(10, 10));
classNamesJList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
classNamesJList_valueChanged(e);
}
});
classNamesJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jScrollPane3.setBorder(BorderFactory.createLineBorder(Color.black));
jScrollPane3.setPreferredSize(new Dimension(100, 100));
gridLayout4.setRows(4);
gridLayout4.setColumns(1);
gridLayout4.setHgap(1);
jScrollPane4.setBorder(BorderFactory.createLineBorder(Color.black));
jScrollPane4.setPreferredSize(new Dimension(100, 100));
pass1TextPane.setBorder(BorderFactory.createRaisedBevelBorder());
pass1TextPane.setToolTipText("");
pass1TextPane.setEditable(false);
pass2TextPane.setBorder(BorderFactory.createRaisedBevelBorder());
pass2TextPane.setEditable(false);
messagesTextPane.setBorder(BorderFactory.createRaisedBevelBorder());
messagesTextPane.setEditable(false);
newFileMenuItem.setText("New...");
newFileMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(78, java.awt.event.KeyEvent.CTRL_MASK, true));
newFileMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
newFileMenuItem_actionPerformed(e);
}
});
pass3aTextPane.setEditable(false);
pass3bTextPane.setEditable(false);
pass3aJList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
pass3aJList_valueChanged(e);
}
});
pass3bJList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
pass3bJList_valueChanged(e);
}
});
jMenu2.setText("Help");
whatisMenuItem.setText("What is...");
whatisMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
whatisMenuItem_actionPerformed(e);
}
});
aboutMenuItem.setText("About");
aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
aboutMenuItem_actionPerformed(e);
}
});
jSplitPane2.add(messagesPanel, JSplitPane.BOTTOM);
messagesPanel.add(messagesScrollPane, null);
messagesScrollPane.getViewport().add(messagesTextPane, null);
jSplitPane2.add(jPanel3, JSplitPane.TOP);
jPanel3.add(jScrollPane3, null);
jScrollPane3.getViewport().add(pass1TextPane, null);
jPanel3.add(jScrollPane4, null);
jPanel3.add(jSplitPane3, null);
jSplitPane3.add(jScrollPane2, JSplitPane.LEFT);
jScrollPane2.getViewport().add(pass3aJList, null);
jSplitPane3.add(jScrollPane5, JSplitPane.RIGHT);
jScrollPane5.getViewport().add(pass3aTextPane, null);
jPanel3.add(jSplitPane4, null);
jSplitPane4.add(jScrollPane6, JSplitPane.LEFT);
jScrollPane6.getViewport().add(pass3bJList, null);
jSplitPane4.add(jScrollPane7, JSplitPane.RIGHT);
jScrollPane7.getViewport().add(pass3bTextPane, null);
jScrollPane4.getViewport().add(pass2TextPane, null);
jSplitPane1.add(jPanel2, JSplitPane.TOP);
jPanel2.add(jScrollPane1, null);
jSplitPane1.add(jPanel1, JSplitPane.BOTTOM);
jPanel1.add(jSplitPane2, null);
jScrollPane1.getViewport().add(classNamesJList, null);
jMenuBar1.add(jMenu1);
jMenuBar1.add(jMenu2);
contentPane.add(jSplitPane1, "jSplitPane1");
jMenu1.add(newFileMenuItem);
jMenu2.add(whatisMenuItem);
jMenu2.add(aboutMenuItem);
jSplitPane2.setDividerLocation(300);
jSplitPane3.setDividerLocation(150);
jSplitPane4.setDividerLocation(150);
}

/** Overridden to stop the application on a closing window. */
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}

synchronized void classNamesJList_valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) return;
current_class = classNamesJList.getSelectedValue().toString();
verify();
classNamesJList.setSelectedValue(current_class, true);
}

private void verify(){
setTitle("PLEASE WAIT");

Verifier v = VerifierFactory.getVerifier(current_class);
v.flush(); // Don't cache the verification result for this class.

VerificationResult vr;

vr = v.doPass1();
if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
pass1TextPane.setText(vr.getMessage());
pass1TextPane.setBackground(Color.red);

pass2TextPane.setText("");
pass2TextPane.setBackground(Color.yellow);
pass3aTextPane.setText("");
pass3aJList.setListData(new Object[0]);
pass3aTextPane.setBackground(Color.yellow);

pass3bTextPane.setText("");
pass3bJList.setListData(new Object[0]);
pass3bTextPane.setBackground(Color.yellow);

}
else{ // Must be VERIFIED_OK, Pass 1 does not know VERIFIED_NOTYET
pass1TextPane.setBackground(Color.green);
pass1TextPane.setText(vr.getMessage());

vr = v.doPass2();
if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
pass2TextPane.setText(vr.getMessage());
pass2TextPane.setBackground(Color.red);

pass3aTextPane.setText("");
pass3aTextPane.setBackground(Color.yellow);
pass3aJList.setListData(new Object[0]);
pass3bTextPane.setText("");
pass3bTextPane.setBackground(Color.yellow);
pass3bJList.setListData(new Object[0]);
}
else{ // must be Verified_OK, because Pass1 was OK (cannot be Verified_NOTYET).
pass2TextPane.setText(vr.getMessage());
pass2TextPane.setBackground(Color.green);

JavaClass jc = Repository.lookupClass(current_class);
/*
boolean all3aok = true;
boolean all3bok = true;
String all3amsg = "";
String all3bmsg = "";
*/

String[] methodnames = new String[jc.getMethods().length];
for (int i=0; i<jc.getMethods().length; i++){
methodnames[i] = jc.getMethods()[i].toString().replace('\n',' ').replace('\t',' ');
}
pass3aJList.setListData(methodnames);
pass3aJList.setSelectionInterval(0,jc.getMethods().length-1);
pass3bJList.setListData(methodnames);
pass3bJList.setSelectionInterval(0,jc.getMethods().length-1);
}

}
String[] msgs = v.getMessages();
messagesTextPane.setBackground(msgs.length == 0? Color.green : Color.yellow);
String allmsgs = "";
for (int i=0; i<msgs.length; i++){
msgs[i] = msgs[i].replace('\n',' ');
allmsgs += msgs[i] + "\n\n";
}
messagesTextPane.setText(allmsgs);

setTitle(current_class + " - " + JUSTICE_VERSION);
}

void newFileMenuItem_actionPerformed(ActionEvent e) {
String classname = JOptionPane.showInputDialog("Please enter the fully qualified name of a class or interface to verify:");
if ((classname == null) || (classname.equals(""))) return;
VerifierFactory.getVerifier(classname); // let observers do the rest.
classNamesJList.setSelectedValue(classname, true);
}

synchronized void pass3aJList_valueChanged(ListSelectionEvent e) {

if (e.getValueIsAdjusting()) return;
Verifier v = VerifierFactory.getVerifier(current_class);

String all3amsg = "";
boolean all3aok = true;
boolean rejected = false;
for (int i=0; i<pass3aJList.getModel().getSize(); i++){

if (pass3aJList.isSelectedIndex(i)){
VerificationResult vr = v.doPass3a(i);

if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
all3aok = false;
rejected = true;
}
all3amsg += "Method '"+Repository.lookupClass(v.getClassName()).getMethods()[i]+"': "+vr.getMessage().replace('\n',' ')+"\n\n";
}
}
pass3aTextPane.setText(all3amsg);
pass3aTextPane.setBackground(all3aok? Color.green : (rejected? Color.red : Color.yellow));

}

synchronized void pass3bJList_valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) return;

Verifier v = VerifierFactory.getVerifier(current_class);

String all3bmsg = "";
boolean all3bok = true;
boolean rejected = false;
for (int i=0; i<pass3bJList.getModel().getSize(); i++){

if (pass3bJList.isSelectedIndex(i)){
VerificationResult vr = v.doPass3b(i);

if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
all3bok = false;
rejected = true;
}
all3bmsg += "Method '"+Repository.lookupClass(v.getClassName()).getMethods()[i]+"': "+vr.getMessage().replace('\n',' ')+"\n\n";
}
}
pass3bTextPane.setText(all3bmsg);
pass3bTextPane.setBackground(all3bok? Color.green : (rejected? Color.red : Color.yellow));

}

void aboutMenuItem_actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(this,
"JustIce is a Java class file verifier.\nIt was implemented by Enver Haase in 2001, 2002.\n<https://jakarta.apache.org/bcel/index.html>",
JUSTICE_VERSION, JOptionPane.INFORMATION_MESSAGE);
}

void whatisMenuItem_actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(this,
"The upper four boxes to the right reflect verification passes according to The Java Virtual Machine Specification.\nThese are (in that order): Pass one, Pass two, Pass three (before data flow analysis), Pass three (data flow analysis).\nThe bottom box to the right shows (warning) messages; warnings do not cause a class to be rejected.",
JUSTICE_VERSION, JOptionPane.INFORMATION_MESSAGE);
}
}

+ 0
- 143
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactory.java View File

@@ -1,143 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;

/**
* This class produces instances of the Verifier class. Its purpose is to make
* sure that they are singleton instances with respect to the class name they
* operate on. That means, for every class (represented by a unique fully qualified
* class name) there is exactly one Verifier.
*
* @version $Id: VerifierFactory.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see org.aspectj.apache.bcel.verifier.Verifier
*/
public class VerifierFactory{

/**
* The HashMap that holds the data about the already-constructed Verifier instances.
*/
private static HashMap<String, Verifier> hashMap = new HashMap<String, Verifier>();

/**
* The VerifierFactoryObserver instances that observe the VerifierFactory.
*/
private static Vector<VerifierFactoryObserver> observers = new Vector<VerifierFactoryObserver>();

/**
* The VerifierFactory is not instantiable.
*/
private VerifierFactory(){}

/**
* Returns the (only) verifier responsible for the class with the given name.
* Possibly a new Verifier object is transparently created.
* @return the (only) verifier responsible for the class with the given name.
*/
public static Verifier getVerifier(String fully_qualified_classname){
// fully_qualified_classname = fully_qualified_classname;

Verifier v = (hashMap.get(fully_qualified_classname));
if (v==null){
v = new Verifier(fully_qualified_classname);
hashMap.put(fully_qualified_classname, v);
notify(fully_qualified_classname);
}

return v;
}

/**
* Notifies the observers of a newly generated Verifier.
*/
private static void notify(String fully_qualified_classname){
// notify the observers
Iterator<VerifierFactoryObserver> i = observers.iterator();
while (i.hasNext()){
VerifierFactoryObserver vfo = i.next();
vfo.update(fully_qualified_classname);
}
}

/**
* Returns all Verifier instances created so far.
* This is useful when a Verifier recursively lets
* the VerifierFactory create other Verifier instances
* and if you want to verify the transitive hull of
* referenced class files.
*/
public static Verifier[] getVerifiers(){
Verifier[] vs = new Verifier[hashMap.values().size()];
return (hashMap.values().toArray(vs)); // Because vs is big enough, vs is used to store the values into and returned!
}

/**
* Adds the VerifierFactoryObserver o to the list of observers.
*/
public static void attach(VerifierFactoryObserver o){
observers.addElement(o);
}

/**
* Removes the VerifierFactoryObserver o from the list of observers.
*/
public static void detach(VerifierFactoryObserver o){
observers.removeElement(o);
}
}

+ 0
- 107
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryListModel.java View File

@@ -1,107 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
/**
* This class implements an adapter; it implements both a Swing ListModel and
* a VerifierFactoryObserver.
*
* @version $Id: VerifierFactoryListModel.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author Enver Haase
*/
public class VerifierFactoryListModel implements org.aspectj.apache.bcel.verifier.VerifierFactoryObserver, javax.swing.ListModel{

private java.util.ArrayList<ListDataListener> listeners = new java.util.ArrayList<ListDataListener>();

private java.util.TreeSet<String> cache = new java.util.TreeSet<String>();

public VerifierFactoryListModel() {
VerifierFactory.attach(this);
update(null); // fill cache.
}

public synchronized void update(String s){
int size = listeners.size();

Verifier[] verifiers = VerifierFactory.getVerifiers();
int num_of_verifiers = verifiers.length;
cache.clear();
for (int i=0; i<num_of_verifiers; i++) {
cache.add(verifiers[i].getClassName());
}

for (int i=0; i<size; i++){
ListDataEvent e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, num_of_verifiers-1);
(listeners.get(i)).contentsChanged(e);
}
}

public synchronized void addListDataListener(javax.swing.event.ListDataListener l){
listeners.add(l);
}

public synchronized void removeListDataListener(javax.swing.event.ListDataListener l){
listeners.remove(l);
}

public synchronized int getSize(){
return cache.size();
}

public synchronized Object getElementAt(int index){
return (cache.toArray())[index];
}
}

+ 0
- 76
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryObserver.java View File

@@ -1,76 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* VerifierFactoryObserver instances are notified when new Verifier
* instances are created.
*
* @version $Id: VerifierFactoryObserver.java,v 1.2 2008/05/28 23:53:00 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*
* @see VerifierFactory#getVerifier(String)
* @see VerifierFactory#getVerifiers()
* @see VerifierFactory#attach(VerifierFactoryObserver)
* @see VerifierFactory#detach(VerifierFactoryObserver)
*/
public interface VerifierFactoryObserver{
/**
* VerifierFactoryObserver instances are notified invoking this method.
* The String argument is the fully qualified class name of a class a
* new Verifier instance created by the VerifierFactory operates on.
*/
public void update(String s);
}

+ 0
- 559
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifyDialog.java View File

@@ -1,559 +0,0 @@
package org.aspectj.apache.bcel.verifier;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.awt.Color;

import org.aspectj.apache.bcel.Repository;
import org.aspectj.apache.bcel.classfile.JavaClass;

/**
* A class for simple graphical class file verification.
* Use the main(String []) method with fully qualified
* class names as arguments to use it as a stand-alone
* application.
* Use the VerifyDialog(String) constructor to use this
* class in your application.
* [This class was created using VisualAge for Java,
* but it does not work under VAJ itself (Version 3.02 JDK 1.2)]
* @version $Id: VerifyDialog.java,v 1.2 2008/05/28 23:53:01 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see #main(String[])
* @see #VerifyDialog(String)
*/
public class VerifyDialog extends javax.swing.JDialog {
/** Machine-generated. */
private javax.swing.JPanel ivjJDialogContentPane = null;
/** Machine-generated. */
private javax.swing.JPanel ivjPass1Panel = null;
/** Machine-generated. */
private javax.swing.JPanel ivjPass2Panel = null;
/** Machine-generated. */
private javax.swing.JPanel ivjPass3Panel = null;
/** Machine-generated. */
private javax.swing.JButton ivjPass1Button = null;
/** Machine-generated. */
private javax.swing.JButton ivjPass2Button = null;
/** Machine-generated. */
private javax.swing.JButton ivjPass3Button = null;
/** Machine-generated. */
IvjEventHandler ivjEventHandler = new IvjEventHandler();

/**
* The class to verify. Default set to 'java.lang.Object'
* in case this class is instantiated via one of the many
* machine-generated constructors.
*/
private String class_name = "java.lang.Object";

/**
* This field is here to count the number of open VerifyDialog
* instances so the JVM can be exited afer every Dialog had been
* closed.
*/
private static int classes_to_verify;

/** Machine-generated. */
class IvjEventHandler implements java.awt.event.ActionListener {
public void actionPerformed(java.awt.event.ActionEvent e) {
if (e.getSource() == VerifyDialog.this.getPass1Button())
connEtoC1(e);
if (e.getSource() == VerifyDialog.this.getPass2Button())
connEtoC2(e);
if (e.getSource() == VerifyDialog.this.getPass3Button())
connEtoC3(e);
if (e.getSource() == VerifyDialog.this.getFlushButton())
connEtoC4(e);
};
};
/** Machine-generated. */
private javax.swing.JButton ivjFlushButton = null;
/** Machine-generated. */
public VerifyDialog() {
super();
initialize();
}

/** Machine-generated. */
public VerifyDialog(java.awt.Dialog owner) {
super(owner);
}

/** Machine-generated. */
public VerifyDialog(java.awt.Dialog owner, String title) {
super(owner, title);
}

/** Machine-generated. */
public VerifyDialog(java.awt.Dialog owner, String title, boolean modal) {
super(owner, title, modal);
}

/** Machine-generated. */
public VerifyDialog(java.awt.Dialog owner, boolean modal) {
super(owner, modal);
}

/** Machine-generated. */
public VerifyDialog(java.awt.Frame owner) {
super(owner);
}

/** Machine-generated. */
public VerifyDialog(java.awt.Frame owner, String title) {
super(owner, title);
}

/** Machine-generated. */
public VerifyDialog(java.awt.Frame owner, String title, boolean modal) {
super(owner, title, modal);
}

/** Machine-generated. */
public VerifyDialog(java.awt.Frame owner, boolean modal) {
super(owner, modal);
}

/**
* Use this constructor if you want a possibility to verify other
* class files than java.lang.Object.
* @param fully_qualified_class_name java.lang.String
*/
public VerifyDialog(String fully_qualified_class_name) {
super();

int dotclasspos = fully_qualified_class_name.lastIndexOf(".class");
if (dotclasspos != -1) fully_qualified_class_name = fully_qualified_class_name.substring(0,dotclasspos);
fully_qualified_class_name = fully_qualified_class_name.replace('/', '.');

class_name = fully_qualified_class_name;
initialize();
}


/** Machine-generated. */
private void connEtoC1(java.awt.event.ActionEvent arg1) {
try {
// user code begin {1}
// user code end
this.pass1Button_ActionPerformed(arg1);
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}

/** Machine-generated. */
private void connEtoC2(java.awt.event.ActionEvent arg1) {
try {
// user code begin {1}
// user code end
this.pass2Button_ActionPerformed(arg1);
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}

/** Machine-generated. */
private void connEtoC3(java.awt.event.ActionEvent arg1) {
try {
// user code begin {1}
// user code end
this.pass4Button_ActionPerformed(arg1);
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}

/** Machine-generated. */
private void connEtoC4(java.awt.event.ActionEvent arg1) {
try {
// user code begin {1}
// user code end
this.flushButton_ActionPerformed(arg1);
// user code begin {2}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}

/** Machine-generated. */
public void flushButton_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
VerifierFactory.getVerifier(class_name).flush();
Repository.removeClass(class_name); // Make sure it will be reloaded.
getPass1Panel().setBackground(Color.gray);
getPass1Panel().repaint();
getPass2Panel().setBackground(Color.gray);
getPass2Panel().repaint();
getPass3Panel().setBackground(Color.gray);
getPass3Panel().repaint();
}

/** Machine-generated. */
private javax.swing.JButton getFlushButton() {
if (ivjFlushButton == null) {
try {
ivjFlushButton = new javax.swing.JButton();
ivjFlushButton.setName("FlushButton");
ivjFlushButton.setText("Flush: Forget old verification results");
ivjFlushButton.setBackground(java.awt.SystemColor.controlHighlight);
ivjFlushButton.setBounds(60, 215, 300, 30);
ivjFlushButton.setForeground(java.awt.Color.red);
ivjFlushButton.setActionCommand("FlushButton");
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjFlushButton;
}

/** Machine-generated. */
private javax.swing.JPanel getJDialogContentPane() {
if (ivjJDialogContentPane == null) {
try {
ivjJDialogContentPane = new javax.swing.JPanel();
ivjJDialogContentPane.setName("JDialogContentPane");
ivjJDialogContentPane.setLayout(null);
getJDialogContentPane().add(getPass1Panel(), getPass1Panel().getName());
getJDialogContentPane().add(getPass3Panel(), getPass3Panel().getName());
getJDialogContentPane().add(getPass2Panel(), getPass2Panel().getName());
getJDialogContentPane().add(getPass1Button(), getPass1Button().getName());
getJDialogContentPane().add(getPass2Button(), getPass2Button().getName());
getJDialogContentPane().add(getPass3Button(), getPass3Button().getName());
getJDialogContentPane().add(getFlushButton(), getFlushButton().getName());
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjJDialogContentPane;
}

/** Machine-generated. */
private javax.swing.JButton getPass1Button() {
if (ivjPass1Button == null) {
try {
ivjPass1Button = new javax.swing.JButton();
ivjPass1Button.setName("Pass1Button");
ivjPass1Button.setText("Pass1: Verify binary layout of .class file");
ivjPass1Button.setBackground(java.awt.SystemColor.controlHighlight);
ivjPass1Button.setBounds(100, 40, 300, 30);
ivjPass1Button.setActionCommand("Button1");
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjPass1Button;
}

/** Machine-generated. */
private javax.swing.JPanel getPass1Panel() {
if (ivjPass1Panel == null) {
try {
ivjPass1Panel = new javax.swing.JPanel();
ivjPass1Panel.setName("Pass1Panel");
ivjPass1Panel.setLayout(null);
ivjPass1Panel.setBackground(java.awt.SystemColor.controlShadow);
ivjPass1Panel.setBounds(30, 30, 50, 50);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjPass1Panel;
}

/** Machine-generated. */
private javax.swing.JButton getPass2Button() {
if (ivjPass2Button == null) {
try {
ivjPass2Button = new javax.swing.JButton();
ivjPass2Button.setName("Pass2Button");
ivjPass2Button.setText("Pass 2: Verify static .class file constraints");
ivjPass2Button.setBackground(java.awt.SystemColor.controlHighlight);
ivjPass2Button.setBounds(100, 100, 300, 30);
ivjPass2Button.setActionCommand("Button2");
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjPass2Button;
}

/** Machine-generated. */
private javax.swing.JPanel getPass2Panel() {
if (ivjPass2Panel == null) {
try {
ivjPass2Panel = new javax.swing.JPanel();
ivjPass2Panel.setName("Pass2Panel");
ivjPass2Panel.setLayout(null);
ivjPass2Panel.setBackground(java.awt.SystemColor.controlShadow);
ivjPass2Panel.setBounds(30, 90, 50, 50);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjPass2Panel;
}

/** Machine-generated. */
private javax.swing.JButton getPass3Button() {
if (ivjPass3Button == null) {
try {
ivjPass3Button = new javax.swing.JButton();
ivjPass3Button.setName("Pass3Button");
ivjPass3Button.setText("Passes 3a+3b: Verify code arrays");
ivjPass3Button.setBackground(java.awt.SystemColor.controlHighlight);
ivjPass3Button.setBounds(100, 160, 300, 30);
ivjPass3Button.setActionCommand("Button2");
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjPass3Button;
}

/** Machine-generated. */
private javax.swing.JPanel getPass3Panel() {
if (ivjPass3Panel == null) {
try {
ivjPass3Panel = new javax.swing.JPanel();
ivjPass3Panel.setName("Pass3Panel");
ivjPass3Panel.setLayout(null);
ivjPass3Panel.setBackground(java.awt.SystemColor.controlShadow);
ivjPass3Panel.setBounds(30, 150, 50, 50);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjPass3Panel;
}

/** Machine-generated. */
private void handleException(java.lang.Throwable exception) {

/* Uncomment the following lines to print uncaught exceptions to stdout */
System.out.println("--------- UNCAUGHT EXCEPTION ---------");
exception.printStackTrace(System.out);
}


/** Machine-generated. */
private void initConnections() throws java.lang.Exception {
// user code begin {1}
// user code end
getPass1Button().addActionListener(ivjEventHandler);
getPass2Button().addActionListener(ivjEventHandler);
getPass3Button().addActionListener(ivjEventHandler);
getFlushButton().addActionListener(ivjEventHandler);
}

/** Machine-generated. */
private void initialize() {
try {
// user code begin {1}
// user code end
setName("VerifyDialog");
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setSize(430, 280);
setVisible(true);
setModal(true);
setResizable(false);
setContentPane(getJDialogContentPane());
initConnections();
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
// user code begin {2}
setTitle("'"+class_name+"' verification - JustIce / BCEL");
// user code end
}
/**
* Verifies one or more class files.
* Verification results are presented graphically: Red means 'rejected',
* green means 'passed' while yellow means 'could not be verified yet'.
* @param args java.lang.String[] fully qualified names of classes to verify.
*/
public static void main(java.lang.String[] args) {
classes_to_verify = args.length;

for (int i=0; i<args.length; i++){

try {
VerifyDialog aVerifyDialog;
aVerifyDialog = new VerifyDialog(args[i]);
aVerifyDialog.setModal(true);
aVerifyDialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
classes_to_verify--;
if (classes_to_verify == 0) System.exit(0);
};
});
aVerifyDialog.setVisible(true);
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of javax.swing.JDialog");
exception.printStackTrace(System.out);
}

}
}

/** Machine-generated. */
public void pass1Button_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
Verifier v = VerifierFactory.getVerifier(class_name);
VerificationResult vr = v.doPass1();
if (vr.getStatus() == VerificationResult.VERIFIED_OK){
getPass1Panel().setBackground(Color.green);
getPass1Panel().repaint();
}
if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
getPass1Panel().setBackground(Color.red);
getPass1Panel().repaint();
}
}

/** Machine-generated. */
public void pass2Button_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
pass1Button_ActionPerformed(actionEvent);

Verifier v = VerifierFactory.getVerifier(class_name);
VerificationResult vr = v.doPass2();
if (vr.getStatus() == VerificationResult.VERIFIED_OK){
getPass2Panel().setBackground(Color.green);
getPass2Panel().repaint();
}
if (vr.getStatus() == VerificationResult.VERIFIED_NOTYET){
getPass2Panel().setBackground(Color.yellow);
getPass2Panel().repaint();
}
if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
getPass2Panel().setBackground(Color.red);
getPass2Panel().repaint();
}
}

/** Machine-generated. */
public void pass4Button_ActionPerformed(java.awt.event.ActionEvent actionEvent) {

pass2Button_ActionPerformed(actionEvent);


Color color = Color.green;

Verifier v = VerifierFactory.getVerifier(class_name);
VerificationResult vr = v.doPass2();
if (vr.getStatus() == VerificationResult.VERIFIED_OK){
JavaClass jc = Repository.lookupClass(class_name);
int nr = jc.getMethods().length;
for (int i=0; i<nr; i++) {
vr = v.doPass3b(i);
if (vr.getStatus() != VerificationResult.VERIFIED_OK){
color = Color.red;
break;
}
}
}
else{
color = Color.yellow;
}

getPass3Panel().setBackground(color);
getPass3Panel().repaint();
}
}

+ 0
- 107
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/AssertionViolatedException.java View File

@@ -1,107 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* Instances of this class should never be thrown. When such an instance is thrown,
* this is due to an INTERNAL ERROR of BCEL's class file verifier &quot;JustIce&quot;.
*
* @version $Id: AssertionViolatedException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public final class AssertionViolatedException extends RuntimeException{
/** The error message. */
private String detailMessage;
/** Constructs a new AssertionViolatedException with null as its error message string. */
public AssertionViolatedException(){
super();
}
/**
* Constructs a new AssertionViolatedException with the specified error message preceded
* by &quot;INTERNAL ERROR: &quot;.
*/
public AssertionViolatedException(String message){
super(message = "INTERNAL ERROR: "+message); // Thanks to Java, the constructor call here must be first.
detailMessage=message;
}
/** Extends the error message with a string before ("pre") and after ("post") the
'old' error message. All of these three strings are allowed to be null, and null
is always replaced by the empty string (""). In particular, after invoking this
method, the error message of this object can no longer be null.
*/
public void extendMessage(String pre, String post){
if (pre == null) pre="";
if (detailMessage == null) detailMessage="";
if (post == null) post="";
detailMessage = pre+detailMessage+post;
}
/**
* Returns the error message string of this AssertionViolatedException object.
* @return the error message string of this AssertionViolatedException.
*/
public String getMessage(){
return detailMessage;
}

/**
* DO NOT USE. It's for experimental testing during development only.
*/
public static void main(String[] args){
AssertionViolatedException ave = new AssertionViolatedException("Oops!");
ave.extendMessage("\nFOUND:\n\t","\nExiting!!\n");
throw ave;
}

}

+ 0
- 79
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/ClassConstraintException.java View File

@@ -1,79 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* Instances of this class are thrown by BCEL's class file verifier "JustIce"
* when a class file to verify does not pass the verification pass 2 as described
* in the Java Virtual Machine specification, 2nd edition.
*
* @version $Id: ClassConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class ClassConstraintException extends VerificationException{
/**
* Constructs a new ClassConstraintException with null as its error message string.
*/
public ClassConstraintException(){
super();
}

/**
* Constructs a new ClassConstraintException with the specified error message.
*/
public ClassConstraintException(String message){
super (message);
}
}

+ 0
- 77
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/CodeConstraintException.java View File

@@ -1,77 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/
/**
* Instances of this class are thrown by BCEL's class file verifier "JustIce" when
* a class file does not pass the verification pass 3. Note that the pass 3 used by
* "JustIce" involves verification that is usually delayed to pass 4.
*
* @version $Id: CodeConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public abstract class CodeConstraintException extends VerificationException{
/**
* Constructs a new CodeConstraintException with null as its error message string.
*/
CodeConstraintException(){
super();
}
/**
* Constructs a new CodeConstraintException with the specified error message.
*/
CodeConstraintException(String message){
super(message);
}
}

+ 0
- 69
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/InvalidMethodException.java View File

@@ -1,69 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/
/**
* Instances of this class are thrown by BCEL's class file verifier "JustIce"
* when the verification of a method is requested that does not exist.
*
* @version $Id: InvalidMethodException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class InvalidMethodException extends RuntimeException{
/** Constructs an InvalidMethodException with the specified detail message. */
public InvalidMethodException(String message){
super(message);
}
}

+ 0
- 74
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LinkingConstraintException.java View File

@@ -1,74 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/
/**
* Instances of this class are thrown by BCEL's class file verifier "JustIce" when
* a class file to verify does not pass the verification pass 3 because of a violation
* of a constraint that is usually only verified at run-time (pass 4).
* The Java Virtual Machine Specification, 2nd edition, states that certain constraints
* are usually verified at run-time for performance reasons (the verification of those
* constraints requires loading in and recursively verifying referenced classes) that
* conceptually belong to pass 3; to be precise, that conceptually belong to the
* data flow analysis of pass 3 (called pass 3b in JustIce).
* These are the checks necessary for resolution: Compare pages 142-143 ("4.9.1 The
* Verification Process") and pages 50-51 ("2.17.3 Linking: Verification, Preparation,
* and Resolution") of the above mentioned book.
* <B>TODO: At this time, this class is not used in JustIce.</B>
*
* @version $Id: LinkingConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class LinkingConstraintException extends StructuralCodeConstraintException{
}

+ 0
- 79
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LoadingException.java View File

@@ -1,79 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* When loading a class file, BCEL will throw an instance of LoadingException if
* the class file is malformed; so it is not conforming to the "Pass 1" verification
* process as described in the Java Virtual Machine specification, 2nd. edition.
* @version $Id: LoadingException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class LoadingException extends VerifierConstraintViolatedException{

/**
* Constructs a new LoadingException with null as its error message string.
*/
public LoadingException(){
super();
}

/**
* Constructs a new LoadingException with the specified error message.
*/
public LoadingException(String message){
super (message);
}
}

+ 0
- 81
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java View File

@@ -1,81 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* A LocalVariableInfoInconsistentException instance is thrown by
* the LocalVariableInfo class when it detects that the information
* it holds is inconsistent; this is normally due to inconsistent
* LocalVariableTable entries in the Code attribute of a certain
* Method object.
*
* @version $Id: LocalVariableInfoInconsistentException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class LocalVariableInfoInconsistentException extends ClassConstraintException{
/**
* Constructs a new LocalVariableInfoInconsistentException with null as its error message string.
*/
public LocalVariableInfoInconsistentException(){
super();
}

/**
* Constructs a new LocalVariableInfoInconsistentException with the specified error message.
*/
public LocalVariableInfoInconsistentException(String message){
super (message);
}
}

+ 0
- 71
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeConstraintException.java View File

@@ -1,71 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* Instances of this class are thrown by BCEL's class file verifier "JustIce" when
* a class file to verify does not pass the verification pass 3 because of a violation
* of a static constraint as described in the Java Virtual Machine Specification,
* 2nd edition, 4.8.1, pages 133-137. The static constraints checking part of pass 3
* is called pass 3a in JustIce.
*
* @version $Id: StaticCodeConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public abstract class StaticCodeConstraintException extends CodeConstraintException{
public StaticCodeConstraintException(String message){
super(message);
}
}

+ 0
- 74
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java View File

@@ -1,74 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* Instances of this class are thrown by BCEL's class file verifier "JustIce" when
* a class file to verify does not pass the verification pass 3 because of a violation
* of a static constraint as described in the Java Virtual Machine Specification,
* Second edition, 4.8.1, pages 133-137. The static constraints checking part of pass 3
* is called pass 3a in JustIce.
* Static constraints on the instructions in the code array are checked early in
* pass 3a and are described on page 134 in the Java Virtual Machine Specification,
* Second Edition.
*
* @version $Id: StaticCodeInstructionConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class StaticCodeInstructionConstraintException extends StaticCodeConstraintException{
public StaticCodeInstructionConstraintException(String message){
super(message);
}
}

+ 0
- 74
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java View File

@@ -1,74 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* Instances of this class are thrown by BCEL's class file verifier "JustIce" when
* a class file to verify does not pass the verification pass 3 because of a violation
* of a static constraint as described in the Java Virtual Machine Specification,
* Second edition, 4.8.1, pages 133-137. The static constraints checking part of pass 3
* is called pass 3a in JustIce.
* Static constraints on the operands of instructions in the code array are checked late in
* pass 3a and are described on page 134-137 in the Java Virtual Machine Specification,
* Second Edition.
*
* @version $Id: StaticCodeInstructionOperandConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class StaticCodeInstructionOperandConstraintException extends StaticCodeConstraintException{
public StaticCodeInstructionOperandConstraintException(String message){
super(message);
}
}

+ 0
- 82
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StructuralCodeConstraintException.java View File

@@ -1,82 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/
/**
* Instances of this class are thrown by BCEL's class file verifier "JustIce" when
* a class file to verify does not pass the verification pass 3 because of a violation
* of a structural constraint as described in the Java Virtual Machine Specification,
* 2nd edition, 4.8.2, pages 137-139.
* Note that the notion of a "structural" constraint is somewhat misleading. Structural
* constraints are constraints on relationships between Java virtual machine instructions.
* These are the constraints where data-flow analysis is needed to verify if they hold.
* The data flow analysis of pass 3 is called pass 3b in JustIce.
*
* @version $Id: StructuralCodeConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class StructuralCodeConstraintException extends CodeConstraintException{
/**
* Constructs a new StructuralCodeConstraintException with the specified error message.
*/
public StructuralCodeConstraintException(String message){
super(message);
}
/**
* Constructs a new StructuralCodeConstraintException with null as its error message string.
*/
public StructuralCodeConstraintException(){
super();
}
}

+ 0
- 76
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/Utility.java View File

@@ -1,76 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.io.*;

/**
* A utility class providing convenience methods concerning Throwable instances.
* @version $Id: Utility.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see java.lang.Throwable
*/
public final class Utility{
/** This class is not instantiable. */
private Utility(){}

/** This method returns the stack trace of a Throwable instance as a String. */
public static String getStackTrace(Throwable t){
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
return sw.toString();
}
}

+ 0
- 82
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/VerificationException.java View File

@@ -1,82 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* Instances of this class are thrown by BCEL's class file verifier "JustIce" when a
* class file to verify does not pass one of the verification passes 2 or 3.
* Note that the pass 3 used by "JustIce" involves verification that is usually
* delayed to pass 4.
* The name of this class is justified by the Java Virtual Machine Specification, 2nd
* edition, page 164, 5.4.1 where verification as a part of the linking process is
* defined to be the verification happening in passes 2 and 3.
*
* @version $Id: VerificationException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public abstract class VerificationException extends VerifierConstraintViolatedException{
/**
* Constructs a new VerificationException with null as its error message string.
*/
VerificationException(){
super();
}
/**
* Constructs a new VerificationException with the specified error message.
*/
VerificationException(String message){
super(message);
}
}

+ 0
- 107
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java View File

@@ -1,107 +0,0 @@
package org.aspectj.apache.bcel.verifier.exc;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* Instances of this class are thrown by BCEL's class file verifier "JustIce"
* whenever
* verification proves that some constraint of a class file (as stated in the
* Java Virtual Machine Specification, Edition 2) is violated.
* This is roughly equivalent to the VerifyError the JVM-internal verifiers
* throw.
*
* @version $Id: VerifierConstraintViolatedException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public abstract class VerifierConstraintViolatedException extends RuntimeException{
// /** The name of the offending class that did not pass the verifier. */
// String name_of_offending_class;

/** The specified error message. */
private String detailMessage;
/**
* Constructs a new VerifierConstraintViolatedException with null as its error message string.
*/
VerifierConstraintViolatedException(){
super();
}
/**
* Constructs a new VerifierConstraintViolatedException with the specified error message.
*/
VerifierConstraintViolatedException(String message){
super(message); // Not that important
detailMessage = message;
}


/** Extends the error message with a string before ("pre") and after ("post") the
'old' error message. All of these three strings are allowed to be null, and null
is always replaced by the empty string (""). In particular, after invoking this
method, the error message of this object can no longer be null.
*/
public void extendMessage(String pre, String post){
if (pre == null) pre="";
if (detailMessage == null) detailMessage="";
if (post == null) post="";
detailMessage = pre+detailMessage+post;
}
/**
* Returns the error message string of this VerifierConstraintViolatedException object.
* @return the error message string of this VerifierConstraintViolatedException.
*/
public String getMessage(){
return detailMessage;
}
}

+ 0
- 25
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/package.html View File

@@ -1,25 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
$Id: package.html,v 1.2 2008/05/28 23:53:00 aclement Exp $
-->
</head>
<body bgcolor="white">

BCEL's verifier JustIce is there to help you dump correct Java class files created or modified with BCEL.

<h2>Package Specification</h2>

This is the top-level package of the JustIce verifier. To actually use it, have a look at the VerifierFactory and
Verifier classes.

<h2>Related Documentation</h2>

For a simple demonstration of JustIce working, please see:
<ul>
<li><a href="https://www.inf.fu-berlin.de/~ehaase/cgi-html/Verifier.html">A WWW front-end for JustIce.</a>
</ul>

</body>
</html>

+ 0
- 79
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/DOUBLE_Upper.java View File

@@ -1,79 +0,0 @@
package org.aspectj.apache.bcel.verifier.statics;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.generic.Type;

/**
* This class represents the upper half of a DOUBLE variable.
* @version $Id: DOUBLE_Upper.java,v 1.2 2008/05/28 23:52:54 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public final class DOUBLE_Upper extends Type{

/** The one and only instance of this class. */
private static DOUBLE_Upper singleInstance = new DOUBLE_Upper();

/** The constructor; this class must not be instantiated from the outside. */
private DOUBLE_Upper(){
super(Constants.T_UNKNOWN, "Long_Upper");
}

/** Use this method to get the single instance of this class. */
public static DOUBLE_Upper theInstance(){
return singleInstance;
}
}

+ 0
- 85
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/IntList.java View File

@@ -1,85 +0,0 @@
package org.aspectj.apache.bcel.verifier.statics;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.util.ArrayList;

/**
* A small utility class representing a set of basic int values.
*
* @version $Id: IntList.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class IntList{
/** The int are stored as Integer objects here. */
private ArrayList<Integer> theList;
/** This constructor creates an empty list. */
IntList(){
theList = new ArrayList<Integer>();
}
/** Adds an element to the list. */
void add(int i){
theList.add(new Integer(i));
}
/** Checks if the specified int is already in the list. */
boolean contains(int i){
Integer[] ints = new Integer[theList.size()];
theList.toArray(ints);
for (int j=0; j<ints.length; j++){
if (i == ints[j].intValue()) return true;
}
return false;
}
}

+ 0
- 79
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LONG_Upper.java View File

@@ -1,79 +0,0 @@
package org.aspectj.apache.bcel.verifier.statics;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.generic.Type;

/**
* This class represents the upper half of a LONG variable.
* @version $Id: LONG_Upper.java,v 1.2 2008/05/28 23:52:54 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public final class LONG_Upper extends Type{

/** The one and only instance of this class. */
private static LONG_Upper singleInstance = new LONG_Upper();

/** The constructor; this class must not be instantiated from the outside. */
private LONG_Upper(){
super(Constants.T_UNKNOWN, "Long_Upper");
}

/** Use this method to get the single instance of this class. */
public static LONG_Upper theInstance(){
return singleInstance;
}
}

+ 0
- 144
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariableInfo.java View File

@@ -1,144 +0,0 @@
package org.aspectj.apache.bcel.verifier.statics;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.generic.Type;
import org.aspectj.apache.bcel.verifier.exc.*;
import java.util.Hashtable;

/**
* A utility class holding the information about
* the name and the type of a local variable in
* a given slot (== index). This information
* often changes in course of byte code offsets.
*
* @version $Id: LocalVariableInfo.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class LocalVariableInfo{

/** The types database. KEY: String representing the offset integer. */
private Hashtable<String, Type> types = new Hashtable<String, Type>();
/** The names database. KEY: String representing the offset integer. */
private Hashtable<String, String> names = new Hashtable<String, String>();

/**
* Adds a name of a local variable and a certain slot to our 'names'
* (Hashtable) database.
*/
private void setName(int offset, String name){
names.put( ((Integer.toString(offset))), name);
}
/**
* Adds a type of a local variable and a certain slot to our 'types'
* (Hashtable) database.
*/
private void setType(int offset, Type t){
types.put( ((Integer.toString(offset))), t);
}

/**
* Returns the type of the local variable that uses this local
* variable slot at the given bytecode offset.
* Care for legal bytecode offsets yourself, otherwise the return value
* might be wrong.
* May return 'null' if nothing is known about the type of this local
* variable slot at the given bytecode offset.
*/
public Type getType(int offset){
return types.get(Integer.toString(offset));
}
/**
* Returns the name of the local variable that uses this local
* variable slot at the given bytecode offset.
* Care for legal bytecode offsets yourself, otherwise the return value
* might be wrong.
* May return 'null' if nothing is known about the type of this local
* variable slot at the given bytecode offset.
*/
public String getName(int offset){
return (names.get(Integer.toString(offset)));
}
/**
* Adds some information about this local variable (slot).
* @throws LocalVariableInfoInconsistentException if the new information conflicts
* with already gathered information.
*/
public void add(String name, int startpc, int length, Type t) throws LocalVariableInfoInconsistentException{
for (int i=startpc; i<=startpc+length; i++){ // incl/incl-notation!
add(i,name,t);
}
}

/**
* Adds information about name and type for a given offset.
* @throws LocalVariableInfoInconsistentException if the new information conflicts
* with already gathered information.
*/
private void add(int offset, String name, Type t) throws LocalVariableInfoInconsistentException{
if (getName(offset) != null){
if (! getName(offset).equals(name)){
throw new LocalVariableInfoInconsistentException("At bytecode offset '"+offset+"' a local variable has two different names: '"+getName(offset)+"' and '"+name+"'.");
}
}
if (getType(offset) != null){
if (! getType(offset).equals(t)){
throw new LocalVariableInfoInconsistentException("At bytecode offset '"+offset+"' a local variable has two different types: '"+getType(offset)+"' and '"+t+"'.");
}
}
setName(offset, name);
setType(offset, t);
}
}

+ 0
- 106
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariablesInfo.java View File

@@ -1,106 +0,0 @@
package org.aspectj.apache.bcel.verifier.statics;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.generic.Type;
import org.aspectj.apache.bcel.verifier.exc.*;

/**
* A utility class holding the information about
* the names and the types of the local variables in
* a given method.
*
* @version $Id: LocalVariablesInfo.java,v 1.2 2008/05/28 23:52:54 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class LocalVariablesInfo{

/** The information about the local variables is stored here. */
private LocalVariableInfo[] localVariableInfos;

/** The constructor. */
LocalVariablesInfo(int max_locals){
localVariableInfos = new LocalVariableInfo[max_locals];
for (int i=0; i<max_locals; i++){
localVariableInfos[i] = new LocalVariableInfo();
}
}

/** Returns the LocalVariableInfo for the given slot. */
public LocalVariableInfo getLocalVariableInfo(int slot){
if (slot < 0 || slot >= localVariableInfos.length){
throw new AssertionViolatedException("Slot number for local variable information out of range.");
}
return localVariableInfos[slot];
}

/**
* Adds information about the local variable in slot 'slot'. Automatically
* adds information for slot+1 if 't' is Type.LONG or Type.DOUBLE.
* @throws LocalVariableInfoInconsistentException if the new information conflicts
* with already gathered information.
*/
public void add(int slot, String name, int startpc, int length, Type t) throws LocalVariableInfoInconsistentException{
// The add operation on LocalVariableInfo may throw the '...Inconsistent...' exception, we don't throw it explicitely here.

if (slot < 0 || slot >= localVariableInfos.length){
throw new AssertionViolatedException("Slot number for local variable information out of range.");
}

localVariableInfos[slot].add(name, startpc, length, t);
if (t == Type.LONG) localVariableInfos[slot+1].add(name, startpc, length, LONG_Upper.theInstance());
if (t == Type.DOUBLE) localVariableInfos[slot+1].add(name, startpc, length, DOUBLE_Upper.theInstance());
}
}

+ 0
- 215
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass1Verifier.java View File

@@ -1,215 +0,0 @@
package org.aspectj.apache.bcel.verifier.statics;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.Repository;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.verifier.PassVerifier;
import org.aspectj.apache.bcel.verifier.VerificationResult;
import org.aspectj.apache.bcel.verifier.Verifier;
import org.aspectj.apache.bcel.verifier.exc.LoadingException;
import org.aspectj.apache.bcel.verifier.exc.Utility;

/**
* This PassVerifier verifies a class file according to pass 1 as
* described in The Java Virtual Machine Specification, 2nd edition.
* More detailed information is to be found at the do_verify() method's
* documentation.
*
* @version $Id: Pass1Verifier.java,v 1.2 2008/05/28 23:52:54 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see #do_verify()
*/
public final class Pass1Verifier extends PassVerifier{
/**
* DON'T USE THIS EVEN PRIVATELY! USE getJavaClass() INSTEAD.
* @see #getJavaClass()
*/
private JavaClass jc;

/**
* The Verifier that created this.
*/
private Verifier myOwner;

/** Used to load in and return the myOwner-matching JavaClass object when needed. Avoids loading in a class file when it's not really needed! */
private JavaClass getJavaClass(){
if (jc == null){
jc = Repository.lookupClass(myOwner.getClassName());
}
return jc;
}

/**
* Should only be instantiated by a Verifier.
*
* @see org.aspectj.apache.bcel.verifier.Verifier
*/
public Pass1Verifier(Verifier owner){
myOwner = owner;
}

/**
* Pass-one verification basically means loading in a class file.
* The Java Virtual Machine Specification is not too precise about
* what makes the difference between passes one and two.
* The answer is that only pass one is performed on a class file as
* long as its resolution is not requested; whereas pass two and
* pass three are performed during the resolution process.
* Only four constraints to be checked are explicitely stated by
* The Java Virtual Machine Specification, 2nd edition:
* <UL>
* <LI>The first four bytes must contain the right magic number (0xCAFEBABE).
* <LI>All recognized attributes must be of the proper length.
* <LI>The class file must not be truncated or have extra bytes at the end.
* <LI>The constant pool must not contain any superficially unrecognizable information.
* </UL>
* A more in-depth documentation of what pass one should do was written by
* <A HREF=mailto:pwfong@cs.sfu.ca>Philip W. L. Fong</A>:
* <UL>
* <LI> the file should not be truncated.
* <LI> the file should not have extra bytes at the end.
* <LI> all variable-length structures should be well-formatted:
* <UL>
* <LI> there should only be constant_pool_count-1 many entries in the constant pool.
* <LI> all constant pool entries should have size the same as indicated by their type tag.
* <LI> there are exactly interfaces_count many entries in the interfaces array of the class file.
* <LI> there are exactly fields_count many entries in the fields array of the class file.
* <LI> there are exactly methods_count many entries in the methods array of the class file.
* <LI> there are exactly attributes_count many entries in the attributes array of the class file, fields, methods, and code attribute.
* <LI> there should be exactly attribute_length many bytes in each attribute. Inconsistency between attribute_length and the actually size of the attribute content should be uncovered. For example, in an Exceptions attribute, the actual number of exceptions as required by the number_of_exceptions field might yeild an attribute size that doesn't match the attribute_length. Such an anomaly should be detected.
* <LI> all attributes should have proper length. In particular, under certain context (e.g. while parsing method_info), recognizable attributes (e.g. "Code" attribute) should have correct format (e.g. attribute_length is 2).
* </UL>
* <LI> Also, certain constant values are checked for validity:
* <UL>
* <LI> The magic number should be 0xCAFEBABE.
* <LI> The major and minor version numbers are valid.
* <LI> All the constant pool type tags are recognizable.
* <LI> All undocumented access flags are masked off before use. Strictly speaking, this is not really a check.
* <LI> The field this_class should point to a string that represents a legal non-array class name, and this name should be the same as the class file being loaded.
* <LI> the field super_class should point to a string that represents a legal non-array class name.
* <LI> Because some of the above checks require cross referencing the constant pool entries, guards are set up to make sure that the referenced entries are of the right type and the indices are within the legal range (0 < index < constant_pool_count).
* </UL>
* <LI> Extra checks done in pass 1:
* <UL>
* <LI> the constant values of static fields should have the same type as the fields.
* <LI> the number of words in a parameter list does not exceed 255 and locals_max.
* <LI> the name and signature of fields and methods are verified to be of legal format.
* </UL>
* </UL>
* (From the Paper <A HREF=https://www.cs.sfu.ca/people/GradStudents/pwfong/personal/JVM/pass1/>The Mysterious Pass One, first draft, September 2, 1997</A>.)
* </BR>
* However, most of this is done by parsing a class file or generating a class file into BCEL's internal data structure.
* <B>Therefore, all that is really done here is look up the class file from BCEL's repository.</B>
* This is also motivated by the fact that some omitted things
* (like the check for extra bytes at the end of the class file) are handy when actually using BCEL to repair a class file (otherwise you would not be
* able to load it into BCEL).
*
* @see org.aspectj.apache.bcel.Repository
*/
public VerificationResult do_verify(){
JavaClass jc;
try{
jc = getJavaClass(); //loads in the class file if not already done.

if (jc != null){
/* If we find more constraints to check, we should do this in an own method. */
if (! myOwner.getClassName().equals(jc.getClassName())){
// This should maybe caught by BCEL: In case of renamed .class files we get wrong
// JavaClass objects here.
throw new LoadingException("Wrong name: the internal name of the .class file '"+jc.getClassName()+"' does not match the file's name '"+myOwner.getClassName()+"'.");
}
}

}
catch(LoadingException e){
return new VerificationResult(VerificationResult.VERIFIED_REJECTED, e.getMessage());
}
catch(ClassFormatError e){
// BCEL sometimes is a little harsh describing exceptual situations.
return new VerificationResult(VerificationResult.VERIFIED_REJECTED, e.getMessage());
}
catch(RuntimeException e){
// BCEL does not catch every possible RuntimeException; e.g. if
// a constant pool index is referenced that does not exist.
return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Parsing via BCEL did not succeed. "+e.getClass().getName()+" occured:\n"+Utility.getStackTrace(e));
}

if (jc != null){
return VerificationResult.VR_OK;
}
else{
//TODO: Maybe change Repository's behaviour to throw a LoadingException instead of just returning "null"
// if a class file cannot be found or in another way be looked up.
return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Repository.lookup() failed. FILE NOT FOUND?");
}
}

/**
* Currently this returns an empty array of String.
* One could parse the error messages of BCEL
* (written to java.lang.System.err) when loading
* a class file such as detecting unknown attributes
* or trailing garbage at the end of a class file.
* However, Markus Dahm does not like the idea so this
* method is currently useless and therefore marked as
* <B>TODO</B>.
*/
public String[] getMessages(){
// This method is only here to override the javadoc-comment.
return super.getMessages();
}

}

+ 0
- 1490
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java
File diff suppressed because it is too large
View File


+ 0
- 1188
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass3aVerifier.java
File diff suppressed because it is too large
View File


+ 0
- 268
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/StringRepresentation.java View File

@@ -1,268 +0,0 @@
package org.aspectj.apache.bcel.verifier.statics;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.classfile.AnnotationDefault;
import org.aspectj.apache.bcel.classfile.Code;
import org.aspectj.apache.bcel.classfile.CodeException;
import org.aspectj.apache.bcel.classfile.ConstantClass;
import org.aspectj.apache.bcel.classfile.ConstantDouble;
import org.aspectj.apache.bcel.classfile.ConstantFieldref;
import org.aspectj.apache.bcel.classfile.ConstantFloat;
import org.aspectj.apache.bcel.classfile.ConstantInteger;
import org.aspectj.apache.bcel.classfile.ConstantInterfaceMethodref;
import org.aspectj.apache.bcel.classfile.ConstantLong;
import org.aspectj.apache.bcel.classfile.ConstantMethodref;
import org.aspectj.apache.bcel.classfile.ConstantNameAndType;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.ConstantString;
import org.aspectj.apache.bcel.classfile.ConstantUtf8;
import org.aspectj.apache.bcel.classfile.ConstantValue;
import org.aspectj.apache.bcel.classfile.Deprecated;
import org.aspectj.apache.bcel.classfile.ExceptionTable;
import org.aspectj.apache.bcel.classfile.Field;
import org.aspectj.apache.bcel.classfile.InnerClass;
import org.aspectj.apache.bcel.classfile.InnerClasses;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.LineNumber;
import org.aspectj.apache.bcel.classfile.LineNumberTable;
import org.aspectj.apache.bcel.classfile.LocalVariable;
import org.aspectj.apache.bcel.classfile.LocalVariableTable;
import org.aspectj.apache.bcel.classfile.LocalVariableTypeTable;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.Node;
import org.aspectj.apache.bcel.classfile.Signature;
import org.aspectj.apache.bcel.classfile.SourceFile;
import org.aspectj.apache.bcel.classfile.StackMap;
import org.aspectj.apache.bcel.classfile.Synthetic;
import org.aspectj.apache.bcel.classfile.Unknown;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisParamAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos;
import org.aspectj.apache.bcel.verifier.exc.AssertionViolatedException;

/**
* BCEL's Node classes (those from the classfile API that <B>accept()</B> Visitor
* instances) have <B>toString()</B> methods that were not designed to be robust,
* this gap is closed by this class.
* When performing class file verification, it may be useful to output which
* entity (e.g. a <B>Code</B> instance) is not satisfying the verifier's
* constraints, but in this case it could be possible for the <B>toString()</B>
* method to throw a RuntimeException.
* A (new StringRepresentation(Node n)).toString() never throws any exception.
* Note that this class also serves as a placeholder for more sophisticated message
* handling in future versions of JustIce.
*
* @version $Id: StringRepresentation.java,v 1.4 2009/09/15 19:40:22 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class StringRepresentation extends org.aspectj.apache.bcel.verifier.EmptyClassVisitor{
/** The string representation, created by a visitXXX() method, output by toString(). */
private String tostring;
/** The node we ask for its string representation. Not really needed; only for debug output. */
private Node n;
/**
* Creates a new StringRepresentation object which is the representation of n.
*
* @see #toString()
*/
public StringRepresentation(Node n){
this.n = n;
n.accept(this); // assign a string representation to field 'tostring' if we know n's class.
}
/**
* Returns the String representation.
*/
public String toString(){
// The run-time check below is needed because we don't want to omit inheritance
// of "EmptyVisitor" and provide a thousand empty methods.
// However, in terms of performance this would be a better idea.
// If some new "Node" is defined in BCEL (such as some concrete "Attribute"), we
// want to know that this class has also to be adapted.
if (tostring == null) throw new AssertionViolatedException("Please adapt '"+getClass()+"' to deal with objects of class '"+n.getClass()+"'.");
return tostring;
}
/**
* Returns the String representation of the Node object obj;
* this is obj.toString() if it does not throw any RuntimeException,
* or else it is a string derived only from obj's class name.
*/
private String toString(Node obj){
String ret;
try{
ret = obj.toString();
}
catch(RuntimeException e){
String s = obj.getClass().getName();
s = s.substring(s.lastIndexOf(".")+1);
ret = "<<"+s+">>";
}
catch(ClassFormatError e){ /* BCEL can be harsh e.g. trying to convert the "signature" of a ReturnaddressType LocalVariable (shouldn't occur, but people do crazy things) */
String s = obj.getClass().getName();
s = s.substring(s.lastIndexOf(".")+1);
ret = "<<"+s+">>";
}
return ret;
}
////////////////////////////////
// Visitor methods start here //
////////////////////////////////
// We don't of course need to call some default implementation:
// e.g. we could also simply output "Code" instead of a possibly
// lengthy Code attribute's toString().
public void visitCode(Code obj){
//tostring = toString(obj);
tostring = "<CODE>"; // We don't need real code outputs.
}
public void visitCodeException(CodeException obj){
tostring = toString(obj);
}
public void visitConstantClass(ConstantClass obj){
tostring = toString(obj);
}
public void visitConstantDouble(ConstantDouble obj){
tostring = toString(obj);
}
public void visitConstantFieldref(ConstantFieldref obj){
tostring = toString(obj);
}
public void visitConstantFloat(ConstantFloat obj){
tostring = toString(obj);
}
public void visitConstantInteger(ConstantInteger obj){
tostring = toString(obj);
}
public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj){
tostring = toString(obj);
}
public void visitConstantLong(ConstantLong obj){
tostring = toString(obj);
}
public void visitConstantMethodref(ConstantMethodref obj){
tostring = toString(obj);
}
public void visitConstantNameAndType(ConstantNameAndType obj){
tostring = toString(obj);
}
public void visitConstantPool(ConstantPool obj){
tostring = toString(obj);
}
public void visitConstantString(ConstantString obj){
tostring = toString(obj);
}
public void visitConstantUtf8(ConstantUtf8 obj){
tostring = toString(obj);
}
public void visitConstantValue(ConstantValue obj){
tostring = toString(obj);
}
public void visitDeprecated(Deprecated obj){
tostring = toString(obj);
}
public void visitExceptionTable(ExceptionTable obj){
tostring = toString(obj);
}
public void visitField(Field obj){
tostring = toString(obj);
}
public void visitInnerClass(InnerClass obj){
tostring = toString(obj);
}
public void visitInnerClasses(InnerClasses obj){
tostring = toString(obj);
}
public void visitJavaClass(JavaClass obj){
tostring = toString(obj);
}
public void visitLineNumber(LineNumber obj){
tostring = toString(obj);
}
public void visitLineNumberTable(LineNumberTable obj){
tostring = "<LineNumberTable: "+toString(obj)+">";
}
public void visitLocalVariable(LocalVariable obj){
tostring = toString(obj);
}
public void visitLocalVariableTable(LocalVariableTable obj){
tostring = "<LocalVariableTable: "+toString(obj)+">";
}
public void visitMethod(Method obj){
tostring = toString(obj);
}
public void visitSignature(Signature obj){
tostring = toString(obj);
}
public void visitSourceFile(SourceFile obj){
tostring = toString(obj);
}
public void visitStackMap(StackMap obj){
tostring = toString(obj);
}
public void visitSynthetic(Synthetic obj){
tostring = toString(obj);
}
public void visitUnknown(Unknown obj){
tostring = toString(obj);
}

public void visitRuntimeVisibleAnnotations(RuntimeVisAnnos obj) {tostring = toString(obj);}
public void visitRuntimeInvisibleAnnotations(RuntimeInvisAnnos obj) {tostring = toString(obj);}
public void visitRuntimeVisibleParameterAnnotations(RuntimeVisParamAnnos obj) {tostring = toString(obj);}
public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisParamAnnos obj) {tostring = toString(obj);}
public void visitAnnotationDefault(AnnotationDefault obj) {tostring = toString(obj);}
public void visitLocalVariableTypeTable(LocalVariableTypeTable obj) {tostring = toString(obj);}
}

+ 0
- 26
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/package.html View File

@@ -1,26 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
$Id: package.html,v 1.2 2008/05/28 23:52:54 aclement Exp $
-->
</head>
<body bgcolor="white">

Provides PassVerifier classes used internally by JustIce. You don't need to bother with them.

<h2>Package Specification</h2>

Contained in this package are PassVerifier classes for use with the JustIce verifier.
Only the passes performing what Sun calls 'static constraints' have PassVerifier classes
here.

<h2>Related Documentation</h2>

For a simple demonstration of JustIce working, please see:
<ul>
<li><a href="https://www.inf.fu-berlin.de/~ehaase/cgi-html/Verifier.html">A WWW front-end for JustIce.</a>
</ul>

</body>
</html>

+ 0
- 456
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ControlFlowGraph.java View File

@@ -1,456 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;

import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.generic.Instruction;
import org.aspectj.apache.bcel.generic.InstructionBranch;
import org.aspectj.apache.bcel.generic.InstructionHandle;
import org.aspectj.apache.bcel.generic.InstructionSelect;
import org.aspectj.apache.bcel.generic.MethodGen;
import org.aspectj.apache.bcel.generic.RET;
import org.aspectj.apache.bcel.verifier.InstructionWalker;
import org.aspectj.apache.bcel.verifier.exc.AssertionViolatedException;
import org.aspectj.apache.bcel.verifier.exc.StructuralCodeConstraintException;

/**
* This class represents a control flow graph of a method.
*
* @version $Id: ControlFlowGraph.java,v 1.4 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class ControlFlowGraph {

/**
* Objects of this class represent a node in a ControlFlowGraph. These nodes are instructions, not basic blocks.
*/
private class InstructionContextImpl implements InstructionContext {

/**
* The TAG field is here for external temporary flagging, such as graph colouring.
*
* @see #getTag()
* @see #setTag(int)
*/
private int TAG;

/**
* The InstructionHandle this InstructionContext is wrapped around.
*/
private final InstructionHandle instruction;

/**
* The 'incoming' execution Frames.
*/
private final HashMap<InstructionContextImpl, Frame> inFrames; // key: the last-executed JSR

/**
* The 'outgoing' execution Frames.
*/
private final HashMap<InstructionContextImpl, Frame> outFrames; // key: the last-executed JSR

/**
* The 'execution predecessors' - a list of type InstructionContext of those instances that have been execute()d before in
* that order.
*/
private ArrayList<InstructionContext> executionPredecessors = null; // Type: InstructionContext

/**
* Creates an InstructionHandleImpl object from an InstructionHandle. Creation of one per InstructionHandle suffices. Don't
* create more.
*/
public InstructionContextImpl(InstructionHandle inst) {
if (inst == null) {
throw new AssertionViolatedException("Cannot instantiate InstructionContextImpl from NULL.");
}

instruction = inst;
inFrames = new java.util.HashMap<InstructionContextImpl, Frame>();
outFrames = new java.util.HashMap<InstructionContextImpl, Frame>();
}

/* Satisfies InstructionContext.getTag(). */
public int getTag() {
return TAG;
}

/* Satisfies InstructionContext.setTag(int). */
public void setTag(int tag) {
TAG = tag;
}

/**
* Returns the exception handlers of this instruction.
*/
public ExceptionHandler[] getExceptionHandlers() {
return exceptionhandlers.getExceptionHandlers(getInstruction());
}

/**
* Returns a clone of the "outgoing" frame situation with respect to the given ExecutionChain.
*/
public Frame getOutFrame(ArrayList<InstructionContext> execChain) {
executionPredecessors = execChain;

Frame org;

InstructionContext jsr = lastExecutionJSR();

org = outFrames.get(jsr);

if (org == null) {
throw new AssertionViolatedException("outFrame not set! This:\n" + this + "\nExecutionChain: "
+ getExecutionChain() + "\nOutFrames: '" + outFrames + "'.");
}
return org.getClone();
}

/**
* "Merges in" (vmspec2, page 146) the "incoming" frame situation; executes the instructions symbolically and therefore
* calculates the "outgoing" frame situation. Returns: True iff the "incoming" frame situation changed after merging with
* "inFrame". The execPreds ArrayList must contain the InstructionContext objects executed so far in the correct order. This
* is just one execution path [out of many]. This is needed to correctly "merge" in the special case of a RET's successor.
* <B>The InstConstraintVisitor and ExecutionVisitor instances must be set up correctly.</B>
*
* @return true - if and only if the "outgoing" frame situation changed from the one before execute()ing.
*/
public boolean execute(Frame inFrame, ArrayList<InstructionContext> execPreds, InstConstraintVisitor icv, ExecutionVisitor ev) {

executionPredecessors = (ArrayList<InstructionContext>) execPreds.clone();

// sanity check
if (lastExecutionJSR() == null && subroutines.subroutineOf(getInstruction()) != subroutines.getTopLevel()) {
throw new AssertionViolatedException("Huh?! Am I '" + this + "' part of a subroutine or not?");
}
if (lastExecutionJSR() != null && subroutines.subroutineOf(getInstruction()) == subroutines.getTopLevel()) {
throw new AssertionViolatedException("Huh?! Am I '" + this + "' part of a subroutine or not?");
}

Frame inF = inFrames.get(lastExecutionJSR());
if (inF == null) {// no incoming frame was set, so set it.
inFrames.put(lastExecutionJSR(), inFrame);
inF = inFrame;
} else {// if there was an "old" inFrame
if (inF.equals(inFrame)) { // shortcut: no need to merge equal frames.
return false;
}
if (!mergeInFrames(inFrame)) {
return false;
}
}

// Now we're sure the inFrame has changed!

// new inFrame is already merged in, see above.
Frame workingFrame = inF.getClone();

try {
// This verifies the InstructionConstraint for the current
// instruction, but does not modify the workingFrame object.
// InstConstraintVisitor icv =
// InstConstraintVisitor.getInstance(VerifierFactory.getVerifier(method_gen.getClassName()));
icv.setFrame(workingFrame);
InstructionWalker.accept(getInstruction().getInstruction(), icv);
} catch (StructuralCodeConstraintException ce) {
ce.extendMessage("", "\nInstructionHandle: " + getInstruction() + "\n");
ce.extendMessage("", "\nExecution Frame:\n" + workingFrame);
extendMessageWithFlow(ce);
throw ce;
}

// This executes the Instruction.
// Therefore the workingFrame object is modified.
// ExecutionVisitor ev = ExecutionVisitor.getInstance(VerifierFactory.getVerifier(method_gen.getClassName()));
ev.setFrame(workingFrame);
InstructionWalker.accept(getInstruction().getInstruction(), ev);
// getInstruction().accept(ExecutionVisitor.withFrame(workingFrame));
outFrames.put(lastExecutionJSR(), workingFrame);

return true; // new inFrame was different from old inFrame so merging them
// yielded a different this.inFrame.
}

/**
* Returns a simple String representation of this InstructionContext.
*/
public String toString() {
// TODO: Put information in the brackets, e.g.
// Is this an ExceptionHandler? Is this a RET? Is this the start of
// a subroutine?
String ret = getInstruction().toString(false) + "\t[InstructionContext]";
return ret;
}

/**
* Does the actual merging (vmspec2, page 146). Returns true IFF this.inFrame was changed in course of merging with inFrame.
*/
private boolean mergeInFrames(Frame inFrame) {
// TODO: Can be performance-improved.
Frame inF = inFrames.get(lastExecutionJSR());
OperandStack oldstack = inF.getStack().getClone();
LocalVariables oldlocals = inF.getLocals().getClone();
try {
inF.getStack().merge(inFrame.getStack());
inF.getLocals().merge(inFrame.getLocals());
} catch (StructuralCodeConstraintException sce) {
extendMessageWithFlow(sce);
throw sce;
}
if (oldstack.equals(inF.getStack()) && oldlocals.equals(inF.getLocals())) {
return false;
} else {
return true;
}
}

/**
* Returns the control flow execution chain. This is built while execute(Frame, ArrayList)-ing the code represented by the
* surrounding ControlFlowGraph.
*/
private String getExecutionChain() {
String s = this.toString();
for (int i = executionPredecessors.size() - 1; i >= 0; i--) {
s = executionPredecessors.get(i) + "\n" + s;
}
return s;
}

/**
* Extends the StructuralCodeConstraintException ("e") object with an at-the-end-extended message. This extended message
* will then reflect the execution flow needed to get to the constraint violation that triggered the throwing of the "e"
* object.
*/
private void extendMessageWithFlow(StructuralCodeConstraintException e) {
String s = "Execution flow:\n";
e.extendMessage("", s + getExecutionChain());
}

/*
* Fulfils the contract of InstructionContext.getInstruction().
*/
public InstructionHandle getInstruction() {
return instruction;
}

/**
* Returns the InstructionContextImpl with an JSR/JSR_W that was last in the ExecutionChain, without a corresponding RET,
* i.e. we were called by this one. Returns null if we were called from the top level.
*/
private InstructionContextImpl lastExecutionJSR() {

int size = executionPredecessors.size();
int retcount = 0;

for (int i = size - 1; i >= 0; i--) {
InstructionContextImpl current = (InstructionContextImpl) executionPredecessors.get(i);
Instruction currentlast = current.getInstruction().getInstruction();
if (currentlast instanceof RET) {
retcount++;
}
if (currentlast.isJsrInstruction()) {
retcount--;
if (retcount == -1) {
return current;
}
}
}
return null;
}

/* Satisfies InstructionContext.getSuccessors(). */
public InstructionContext[] getSuccessors() {
return contextsOf(_getSuccessors());
}

/**
* A utility method that calculates the successors of a given InstructionHandle That means, a RET does have successors as
* defined here. A JsrInstruction has its target as its successor (opposed to its physical successor) as defined here.
*/
// TODO: implement caching!
private InstructionHandle[] _getSuccessors() {
final InstructionHandle[] empty = new InstructionHandle[0];
final InstructionHandle[] single = new InstructionHandle[1];
final InstructionHandle[] pair = new InstructionHandle[2];

Instruction inst = getInstruction().getInstruction();

if (inst instanceof RET) {
Subroutine s = subroutines.subroutineOf(getInstruction());
if (s == null) { // return empty; // RET in dead code. "empty" would be the correct answer, but we know something
// about the surrounding project...
throw new AssertionViolatedException("Asking for successors of a RET in dead code?!");
}
// TODO: remove
throw new AssertionViolatedException("DID YOU REALLY WANT TO ASK FOR RET'S SUCCS?");
/*
* InstructionHandle[] jsrs = s.getEnteringJsrInstructions(); InstructionHandle[] ret = new
* InstructionHandle[jsrs.length]; for (int i=0; i<jsrs.length; i++){ ret[i] = jsrs[i].getNext(); } return ret;
*/
}

// Terminates method normally.
if (inst.isReturnInstruction()) {
return empty;
}

// Terminates method abnormally, because JustIce mandates
// subroutines not to be protected by exception handlers.
if (inst.getOpcode() == Constants.ATHROW) {
return empty;
}

// See method comment.
if (inst.isJsrInstruction()) {
single[0] = ((InstructionBranch) inst).getTarget();
return single;
}

if (inst.getOpcode() == Constants.GOTO || inst.getOpcode() == Constants.GOTO_W) {
single[0] = ((InstructionBranch) inst).getTarget();
return single;
}

if (inst instanceof InstructionBranch) {
if (inst instanceof InstructionSelect) {
// BCEL's getTargets() returns only the non-default targets,
// thanks to Eli Tilevich for reporting.
InstructionHandle[] matchTargets = ((InstructionSelect) inst).getTargets();
InstructionHandle[] ret = new InstructionHandle[matchTargets.length + 1];
ret[0] = ((InstructionSelect) inst).getTarget();
System.arraycopy(matchTargets, 0, ret, 1, matchTargets.length);
return ret;
} else {
pair[0] = getInstruction().getNext();
pair[1] = ((InstructionBranch) inst).getTarget();
return pair;
}
}

// default case: Fall through.
single[0] = getInstruction().getNext();
return single;
}

} // End Inner InstructionContextImpl Class.

/** The MethofGen object we're working on. */
private final MethodGen method_gen;

/** The Subroutines object for the method whose control flow is represented by this ControlFlowGraph. */
private final Subroutines subroutines;

/** The ExceptionHandlers object for the method whose control flow is represented by this ControlFlowGraph. */
private final ExceptionHandlers exceptionhandlers;

/** All InstructionContext instances of this ControlFlowGraph. */
private final Hashtable<InstructionHandle, InstructionContextImpl> instructionContexts = new Hashtable<InstructionHandle, InstructionContextImpl>(); // keys: InstructionHandle, values: InstructionContextImpl

/**
* A Control Flow Graph.
*/
public ControlFlowGraph(MethodGen method_gen) {
subroutines = new Subroutines(method_gen);
exceptionhandlers = new ExceptionHandlers(method_gen);

InstructionHandle[] instructionhandles = method_gen.getInstructionList().getInstructionHandles();
for (int i = 0; i < instructionhandles.length; i++) {
instructionContexts.put(instructionhandles[i], new InstructionContextImpl(instructionhandles[i]));
}

this.method_gen = method_gen;
}

/**
* Returns the InstructionContext of a given instruction.
*/
public InstructionContext contextOf(InstructionHandle inst) {
InstructionContext ic = instructionContexts.get(inst);
if (ic == null) {
throw new AssertionViolatedException("InstructionContext requested for an InstructionHandle that's not known!");
}
return ic;
}

/**
* Returns the InstructionContext[] of a given InstructionHandle[], in a naturally ordered manner.
*/
public InstructionContext[] contextsOf(InstructionHandle[] insts) {
InstructionContext[] ret = new InstructionContext[insts.length];
for (int i = 0; i < insts.length; i++) {
ret[i] = contextOf(insts[i]);
}
return ret;
}

/**
* Returns an InstructionContext[] with all the InstructionContext instances for the method whose control flow is represented by
* this ControlFlowGraph <B>(NOT ORDERED!)</B>.
*/
public InstructionContext[] getInstructionContexts() {
InstructionContext[] ret = new InstructionContext[instructionContexts.values().size()];
return instructionContexts.values().toArray(ret);
}

/**
* Returns true, if and only if the said instruction is not reachable; that means, if it not part of this ControlFlowGraph.
*/
public boolean isDead(InstructionHandle i) {
return instructionContexts.containsKey(i);
}
}

+ 0
- 93
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandler.java View File

@@ -1,93 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.generic.*;

/**
* This class represents an exception handler; that is, an ObjectType
* representing a subclass of java.lang.Throwable and the instruction
* the handler starts off (represented by an InstructionContext).
*
* @version $Id: ExceptionHandler.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class ExceptionHandler{
/** The type of the exception to catch. NULL means ANY. */
private ObjectType catchtype;

/** The InstructionHandle where the handling begins. */
private InstructionHandle handlerpc;

/** Leave instance creation to JustIce. */
ExceptionHandler(ObjectType catch_type, InstructionHandle handler_pc){
catchtype = catch_type;
handlerpc = handler_pc;
}

/**
* Returns the type of the exception that's handled. <B>'null' means 'ANY'.</B>
*/
public ObjectType getExceptionType(){
return catchtype;
}

/**
* Returns the InstructionHandle where the handler starts off.
*/
public InstructionHandle getHandlerStart(){
return handlerpc;
}
}

+ 0
- 108
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandlers.java View File

@@ -1,108 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.generic.*;

import java.util.HashSet;
import java.util.Hashtable;

/**
* This class allows easy access to ExceptionHandler objects.
*
* @version $Id: ExceptionHandlers.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class ExceptionHandlers{
/**
* The ExceptionHandler instances.
* Key: InstructionHandle objects, Values: HashSet<ExceptionHandler> instances.
*/
private Hashtable<InstructionHandle, HashSet<ExceptionHandler>> exceptionhandlers;

/**
* Constructor. Creates a new ExceptionHandlers instance.
*/
public ExceptionHandlers(MethodGen mg){
exceptionhandlers = new Hashtable<InstructionHandle, HashSet<ExceptionHandler>>();
CodeExceptionGen[] cegs = mg.getExceptionHandlers();
for (int i=0; i<cegs.length; i++){
ExceptionHandler eh = new ExceptionHandler(cegs[i].getCatchType(), cegs[i].getHandlerPC());
for (InstructionHandle ih=cegs[i].getStartPC(); ih != cegs[i].getEndPC().getNext(); ih=ih.getNext()){
HashSet<ExceptionHandler> hs;
hs = exceptionhandlers.get(ih);
if (hs == null){
hs = new HashSet<ExceptionHandler>();
exceptionhandlers.put(ih, hs);
}
hs.add(eh);
}
}
}

/**
* Returns all the ExceptionHandler instances representing exception
* handlers that protect the instruction ih.
*/
public ExceptionHandler[] getExceptionHandlers(InstructionHandle ih){
HashSet hs = exceptionhandlers.get(ih);
if (hs == null) return new ExceptionHandler[0];
else{
ExceptionHandler[] ret = new ExceptionHandler[hs.size()];
return (ExceptionHandler[]) (hs.toArray(ret));
}
}

}

+ 0
- 1136
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExecutionVisitor.java
File diff suppressed because it is too large
View File


+ 0
- 150
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Frame.java View File

@@ -1,150 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/


/**
* This class represents a JVM execution frame; that means,
* a local variable array and an operand stack.
*
* @version $Id: Frame.java,v 1.2 2008/05/28 23:53:03 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/

public class Frame{

/**
* For instance initialization methods, it is important to remember
* which instance it is that is not initialized yet. It will be
* initialized invoking another constructor later.
* NULL means the instance already *is* initialized.
*/
protected static UninitializedObjectType _this;

/**
*
*/
private LocalVariables locals;

/**
*
*/
private OperandStack stack;

/**
*
*/
public Frame(int maxLocals, int maxStack){
locals = new LocalVariables(maxLocals);
stack = new OperandStack(maxStack);
}

/**
*
*/
public Frame(LocalVariables locals, OperandStack stack){
this.locals = locals;
this.stack = stack;
}

/**
*
*/
protected Object clone(){
Frame f = new Frame(locals.getClone(), stack.getClone());
return f;
}

/**
*
*/
public Frame getClone(){
return (Frame) clone();
}

/**
*
*/
public LocalVariables getLocals(){
return locals;
}

/**
*
*/
public OperandStack getStack(){
return stack;
}

/**
*
*/
public boolean equals(Object o){
if (!(o instanceof Frame)) return false; // implies "null" is non-equal.
Frame f = (Frame) o;
return this.stack.equals(f.stack) && this.locals.equals(f.locals);
}

/**
* Returns a String representation of the Frame instance.
*/
public String toString(){
String s="Local Variables:\n";
s += locals;
s += "OperandStack:\n";
s += stack;
return s;
}
}

+ 0
- 66
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/GenericArray.java View File

@@ -1,66 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* A placeholder class that can be used to create an ObjectType of which
* has some of the properties arrays have. They implement java.lang.Cloneable
* and java.io.Serializable and they extend java.lang.Object.
*
* @version $Id: GenericArray.java,v 1.2 2008/05/28 23:53:03 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class GenericArray extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable{
}

+ 0
- 2444
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstConstraintVisitor.java
File diff suppressed because it is too large
View File


+ 0
- 141
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstructionContext.java View File

@@ -1,141 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.util.ArrayList;

import org.aspectj.apache.bcel.generic.InstructionHandle;

/**
* An InstructionContext offers convenient access
* to information like control flow successors and
* such.
*
* @version $Id: InstructionContext.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public interface InstructionContext{

/**
* The getTag and setTag methods may be used for
* temporary flagging, such as graph colouring.
* Nothing in the InstructionContext object depends
* on the value of the tag. JustIce does not use it.
*
* @see #setTag(int tag)
*/
public int getTag();

/**
* The getTag and setTag methods may be used for
* temporary flagging, such as graph colouring.
* Nothing in the InstructionContext object depends
* on the value of the tag. JustIce does not use it.
*
* @see #getTag()
*/
public void setTag(int tag);

/**
* This method symbolically executes the Instruction
* held in the InstructionContext.
* It "merges in" the incoming execution frame situation
* (see The Java Virtual Machine Specification, 2nd
* edition, page 146).
* By so doing, the outgoing execution frame situation
* is calculated.
*
* This method is JustIce-specific and is usually of
* no sense for users of the ControlFlowGraph class.
* They should use getInstruction().accept(Visitor),
* possibly in conjunction with the ExecutionVisitor.
*
*
* @see ControlFlowGraph
* @see ExecutionVisitor
* @see #getOutFrame(ArrayList)
* @return true - if and only if the "outgoing" frame situation
* changed from the one before execute()ing.
*/
boolean execute(Frame inFrame, ArrayList<InstructionContext> executionPredecessors, InstConstraintVisitor icv, ExecutionVisitor ev);

/**
* This method returns the outgoing execution frame situation;
* therefore <B>it has to be calculated by execute(Frame, ArrayList)
* first.</B>
*
* @see #execute(Frame, ArrayList, InstConstraintVisitor, ExecutionVisitor)
*/
Frame getOutFrame(ArrayList<InstructionContext> executionPredecessors);
/**
* Returns the InstructionHandle this InstructionContext is wrapped around.
*
* @return The InstructionHandle this InstructionContext is wrapped around.
*/
InstructionHandle getInstruction();

/**
* Returns the usual control flow successors.
* @see #getExceptionHandlers()
*/
InstructionContext[] getSuccessors();

/**
* Returns the exception handlers that protect this instruction.
* They are special control flow successors.
*/
ExceptionHandler[] getExceptionHandlers();
}

+ 0
- 229
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/LocalVariables.java View File

@@ -1,229 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.generic.Type;
import org.aspectj.apache.bcel.generic.ReferenceType;
import org.aspectj.apache.bcel.verifier.exc.*;

/**
* This class implements an array of local variables used for symbolic JVM
* simulation.
*
* @version $Id: LocalVariables.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class LocalVariables{
/** The Type[] containing the local variable slots. */
private Type[] locals;

/**
* Creates a new LocalVariables object.
*/
public LocalVariables(int maxLocals){
locals = new Type[maxLocals];
for (int i=0; i<maxLocals; i++){
locals[i] = Type.UNKNOWN;
}
}

/**
* Returns a deep copy of this object; i.e. the clone
* operates on a new local variable array.
* However, the Type objects in the array are shared.
*/
protected Object clone(){
LocalVariables lvs = new LocalVariables(locals.length);
for (int i=0; i<locals.length; i++){
lvs.locals[i] = this.locals[i];
}
return lvs;
}

/**
* Returns the type of the local variable slot i.
*/
public Type get(int i){
return locals[i];
}

/**
* Returns a (correctly typed) clone of this object.
* This is equivalent to ((LocalVariables) this.clone()).
*/
public LocalVariables getClone(){
return (LocalVariables) this.clone();
}

/**
* Returns the number of local variable slots this
* LocalVariables instance has.
*/
public int maxLocals(){
return locals.length;
}

/**
* Sets a new Type for the given local variable slot.
*/
public void set(int i, Type type){
if (type == Type.BYTE || type == Type.SHORT || type == Type.BOOLEAN || type == Type.CHAR){
throw new AssertionViolatedException("LocalVariables do not know about '"+type+"'. Use Type.INT instead.");
}
locals[i] = type;
}

/*
* Fulfills the general contract of Object.equals().
*/
public boolean equals(Object o){
if (!(o instanceof LocalVariables)) return false;
LocalVariables lv = (LocalVariables) o;
if (this.locals.length != lv.locals.length) return false;
for (int i=0; i<this.locals.length; i++){
if (!this.locals[i].equals(lv.locals[i])){
//System.out.println(this.locals[i]+" is not "+lv.locals[i]);
return false;
}
}
return true;
}
/**
* Merges two local variables sets as described in the Java Virtual Machine Specification,
* Second Edition, section 4.9.2, page 146.
*/
public void merge(LocalVariables lv){

if (this.locals.length != lv.locals.length){
throw new AssertionViolatedException("Merging LocalVariables of different size?!? From different methods or what?!?");
}

for (int i=0; i<locals.length; i++){
merge(lv, i);
}
}
/**
* Merges a single local variable.
*
* @see #merge(LocalVariables)
*/
private void merge(LocalVariables lv, int i){
// We won't accept an unitialized object if we know it was initialized;
// compare vmspec2, 4.9.4, last paragraph.
if ( (!(locals[i] instanceof UninitializedObjectType)) && (lv.locals[i] instanceof UninitializedObjectType) ){
throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object in the local variables detected.");
}
// Even harder, what about _different_ uninitialized object types?!
if ( (!(locals[i].equals(lv.locals[i]))) && (locals[i] instanceof UninitializedObjectType) && (lv.locals[i] instanceof UninitializedObjectType) ){
throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object in the local variables detected.");
}
// If we just didn't know that it was initialized, we have now learned.
if (locals[i] instanceof UninitializedObjectType){
if (! (lv.locals[i] instanceof UninitializedObjectType)){
locals[i] = ((UninitializedObjectType) locals[i]).getInitialized();
}
}
if ((locals[i] instanceof ReferenceType) && (lv.locals[i] instanceof ReferenceType)){
if (! locals[i].equals(lv.locals[i])){ // needed in case of two UninitializedObjectType instances
Type sup = ((ReferenceType) locals[i]).getFirstCommonSuperclass((ReferenceType) (lv.locals[i]));

if (sup != null){
locals[i] = sup;
}
else{
// We should have checked this in Pass2!
throw new AssertionViolatedException("Could not load all the super classes of '"+locals[i]+"' and '"+lv.locals[i]+"'.");
}
}
}
else{
if (! (locals[i].equals(lv.locals[i])) ){
/*TODO
if ((locals[i] instanceof org.aspectj.apache.bcel.generic.ReturnaddressType) && (lv.locals[i] instanceof org.aspectj.apache.bcel.generic.ReturnaddressType)){
//System.err.println("merging "+locals[i]+" and "+lv.locals[i]);
throw new AssertionViolatedException("Merging different ReturnAddresses: '"+locals[i]+"' and '"+lv.locals[i]+"'.");
}
*/
locals[i] = Type.UNKNOWN;
}
}
}

/**
* Returns a String representation of this object.
*/
public String toString(){
String s = new String();
for (int i=0; i<locals.length; i++){
s += Integer.toString(i)+": "+locals[i]+"\n";
}
return s;
}

/**
* Replaces all occurences of u in this local variables set
* with an "initialized" ObjectType.
*/
public void initializeObject(UninitializedObjectType u){
for (int i=0; i<locals.length; i++){
if (locals[i] == u){
locals[i] = u.getInitialized();
}
}
}
}

+ 0
- 275
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/OperandStack.java View File

@@ -1,275 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.generic.*;
import org.aspectj.apache.bcel.verifier.exc.*;
import java.util.*;

/**
* This class implements a stack used for symbolic JVM stack simulation.
* [It's used an an operand stack substitute.]
* Elements of this stack are org.aspectj.apache.bcel.generic.Type objects.
*
* @version $Id: OperandStack.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class OperandStack{

/** We hold the stack information here. */
private ArrayList<Type> stack = new ArrayList<Type>();

/** The maximum number of stack slots this OperandStack instance may hold. */
private int maxStack;

/**
* Creates an empty stack with a maximum of maxStack slots.
*/
public OperandStack(int maxStack){
this.maxStack = maxStack;
}

/**
* Creates an otherwise empty stack with a maximum of maxStack slots and
* the ObjectType 'obj' at the top.
*/
public OperandStack(int maxStack, ObjectType obj){
this.maxStack = maxStack;
this.push(obj);
}
/**
* Returns a deep copy of this object; that means, the clone operates
* on a new stack. However, the Type objects on the stack are
* shared.
*/
protected Object clone(){
OperandStack newstack = new OperandStack(this.maxStack);
newstack.stack = (ArrayList<Type>) this.stack.clone();
return newstack;
}

/**
* Clears the stack.
*/
public void clear(){
stack = new ArrayList<Type>();
}

/**
* Returns true if and only if this OperandStack
* equals another, meaning equal lengths and equal
* objects on the stacks.
*/
public boolean equals(Object o){
if (!(o instanceof OperandStack)) return false;
OperandStack s = (OperandStack) o;
return this.stack.equals(s.stack);
}

/**
* Returns a (typed!) clone of this.
*
* @see #clone()
*/
public OperandStack getClone(){
return (OperandStack) this.clone();
}

/**
* Returns true IFF this OperandStack is empty.
*/
public boolean isEmpty(){
return stack.isEmpty();
}

/**
* Returns the number of stack slots this stack can hold.
*/
public int maxStack(){
return this.maxStack;
}

/**
* Returns the element on top of the stack. The element is not popped off the stack!
*/
public Type peek(){
return peek(0);
}

/**
* Returns the element that's i elements below the top element; that means,
* iff i==0 the top element is returned. The element is not popped off the stack!
*/
public Type peek(int i){
return stack.get(size()-i-1);
}

/**
* Returns the element on top of the stack. The element is popped off the stack.
*/
public Type pop(){
Type e = stack.remove(size()-1);
return e;
}

/**
* Pops i elements off the stack. ALWAYS RETURNS "null"!!!
*/
public Type pop(int i){
for (int j=0; j<i; j++){
pop();
}
return null;
}

/**
* Pushes a Type object onto the stack.
*/
public void push(Type type){
if (type == null) throw new AssertionViolatedException("Cannot push NULL onto OperandStack.");
if (type == Type.BOOLEAN || type == Type.CHAR || type == Type.BYTE || type == Type.SHORT){
throw new AssertionViolatedException("The OperandStack does not know about '"+type+"'; use Type.INT instead.");
}
if (slotsUsed() >= maxStack){
throw new AssertionViolatedException("OperandStack too small, should have thrown proper Exception elsewhere. Stack: "+this);
}
stack.add(type);
}

/**
* Returns the size of this OperandStack; that means, how many Type objects there are.
*/
int size(){
return stack.size();
}

/**
* Returns the number of stack slots used.
* @see #maxStack()
*/
public int slotsUsed(){
/* XXX change this to a better implementation using a variable
that keeps track of the actual slotsUsed()-value monitoring
all push()es and pop()s.
*/
int slots = 0;
for (int i=0; i<stack.size(); i++){
slots += peek(i).getSize();
}
return slots;
}

/**
* Returns a String representation of this OperandStack instance.
*/
public String toString(){
String s = "Slots used: "+slotsUsed()+" MaxStack: "+maxStack+".\n";
for (int i=0; i<size(); i++){
s+=peek(i)+" (Size: "+peek(i).getSize()+")\n";
}
return s;
}

/**
* Merges another stack state into this instance's stack state.
* See the Java Virtual Machine Specification, Second Edition, page 146: 4.9.2
* for details.
*/
public void merge(OperandStack s){
if ( (slotsUsed() != s.slotsUsed()) || (size() != s.size()) )
throw new StructuralCodeConstraintException("Cannot merge stacks of different size:\nOperandStack A:\n"+this+"\nOperandStack B:\n"+s);

for (int i=0; i<size(); i++){
// If the object _was_ initialized and we're supposed to merge
// in some uninitialized object, we reject the code (see vmspec2, 4.9.4, last paragraph).
if ( (! (stack.get(i) instanceof UninitializedObjectType)) && (s.stack.get(i) instanceof UninitializedObjectType) ){
throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object on the stack detected.");
}
// Even harder, we're not initialized but are supposed to broaden
// the known object type
if ( (!(stack.get(i).equals(s.stack.get(i)))) && (stack.get(i) instanceof UninitializedObjectType) && (!(s.stack.get(i) instanceof UninitializedObjectType))){
throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object on the stack detected.");
}
// on the other hand...
if (stack.get(i) instanceof UninitializedObjectType){ //if we have an uninitialized object here
if (! (s.stack.get(i) instanceof UninitializedObjectType)){ //that has been initialized by now
stack.set(i, ((UninitializedObjectType) (stack.get(i))).getInitialized() ); //note that.
}
}
if (! stack.get(i).equals(s.stack.get(i))){
if ( (stack.get(i) instanceof ReferenceType) &&
(s.stack.get(i) instanceof ReferenceType) ){
stack.set(i, ((ReferenceType) stack.get(i)).getFirstCommonSuperclass((ReferenceType) (s.stack.get(i))));
}
else{
throw new StructuralCodeConstraintException("Cannot merge stacks of different types:\nStack A:\n"+this+"\nStack B:\n"+s);
}
}
}
}

/**
* Replaces all occurences of u in this OperandStack instance
* with an "initialized" ObjectType.
*/
public void initializeObject(UninitializedObjectType u){
for (int i=0; i<stack.size(); i++){
if (stack.get(i) == u){
stack.set(i, u.getInitialized());
}
}
}

}

+ 0
- 377
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Pass3bVerifier.java View File

@@ -1,377 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Random;
import java.util.Vector;

import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.Repository;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.generic.InstructionBranch;
import org.aspectj.apache.bcel.generic.InstructionHandle;
import org.aspectj.apache.bcel.generic.MethodGen;
import org.aspectj.apache.bcel.generic.ObjectType;
import org.aspectj.apache.bcel.generic.RET;
import org.aspectj.apache.bcel.generic.ReturnaddressType;
import org.aspectj.apache.bcel.generic.Type;
import org.aspectj.apache.bcel.verifier.PassVerifier;
import org.aspectj.apache.bcel.verifier.VerificationResult;
import org.aspectj.apache.bcel.verifier.Verifier;
import org.aspectj.apache.bcel.verifier.exc.AssertionViolatedException;
import org.aspectj.apache.bcel.verifier.exc.VerifierConstraintViolatedException;

/**
* This PassVerifier verifies a method of class file according to pass 3,
* so-called structural verification as described in The Java Virtual Machine
* Specification, 2nd edition.
* More detailed information is to be found at the do_verify() method's
* documentation.
*
* @version $Id: Pass3bVerifier.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see #do_verify()
*/

public final class Pass3bVerifier extends PassVerifier{
/* TODO: Throughout pass 3b, upper halves of LONG and DOUBLE
are represented by Type.UNKNOWN. This should be changed
in favour of LONG_Upper and DOUBLE_Upper as in pass 2. */

/**
* An InstructionContextQueue is a utility class that holds
* (InstructionContext, ArrayList) pairs in a Queue data structure.
* This is used to hold information about InstructionContext objects
* externally --- i.e. that information is not saved inside the
* InstructionContext object itself. This is useful to save the
* execution path of the symbolic execution of the
* Pass3bVerifier - this is not information
* that belongs into the InstructionContext object itself.
* Only at "execute()"ing
* time, an InstructionContext object will get the current information
* we have about its symbolic execution predecessors.
*/
private static final class InstructionContextQueue{
private Vector<InstructionContext> ics = new Vector<InstructionContext>(); // Type: InstructionContext
private Vector<ArrayList<InstructionContext>> ecs = new Vector<ArrayList<InstructionContext>>(); // Type: ArrayList (of InstructionContext)
public void add(InstructionContext ic, ArrayList<InstructionContext> executionChain){
ics.add(ic);
ecs.add(executionChain);
}
public boolean isEmpty(){
return ics.isEmpty();
}
public void remove(){
this.remove(0);
}
public void remove(int i){
ics.remove(i);
ecs.remove(i);
}
public InstructionContext getIC(int i){
return ics.get(i);
}
public ArrayList<InstructionContext> getEC(int i){
return ecs.get(i);
}
public int size(){
return ics.size();
}
} // end Inner Class InstructionContextQueue

/** In DEBUG mode, the verification algorithm is not randomized. */
private static final boolean DEBUG = true;

/** The Verifier that created this. */
private Verifier myOwner;

/** The method number to verify. */
private int method_no;

/**
* This class should only be instantiated by a Verifier.
*
* @see org.aspectj.apache.bcel.verifier.Verifier
*/
public Pass3bVerifier(Verifier owner, int method_no){
myOwner = owner;
this.method_no = method_no;
}

/**
* Whenever the outgoing frame
* situation of an InstructionContext changes, all its successors are
* put [back] into the queue [as if they were unvisited].
* The proof of termination is about the existence of a
* fix point of frame merging.
*/
private void circulationPump(ControlFlowGraph cfg, InstructionContext start, Frame vanillaFrame, InstConstraintVisitor icv, ExecutionVisitor ev){
final Random random = new Random();
InstructionContextQueue icq = new InstructionContextQueue();
start.execute(vanillaFrame, new ArrayList<InstructionContext>(), icv, ev); // new ArrayList() <=> no Instruction was executed before
// => Top-Level routine (no jsr call before)
icq.add(start, new ArrayList<InstructionContext>());

// LOOP!
while (!icq.isEmpty()){
InstructionContext u;
ArrayList<InstructionContext> ec;
if (!DEBUG){
int r = random.nextInt(icq.size());
u = icq.getIC(r);
ec = icq.getEC(r);
icq.remove(r);
}
else{
u = icq.getIC(0);
ec = icq.getEC(0);
icq.remove(0);
}
ArrayList<InstructionContext> oldchain = (ArrayList<InstructionContext>) (ec.clone());
ArrayList<InstructionContext> newchain = (ArrayList<InstructionContext>) (ec.clone());
newchain.add(u);

if ((u.getInstruction().getInstruction()) instanceof RET){
//System.err.println(u);
// We can only follow _one_ successor, the one after the
// JSR that was recently executed.
RET ret = (RET) (u.getInstruction().getInstruction());
ReturnaddressType t = (ReturnaddressType) u.getOutFrame(oldchain).getLocals().get(ret.getIndex());
InstructionContext theSuccessor = cfg.contextOf(t.getTarget());

// Sanity check
InstructionContext lastJSR = null;
int skip_jsr = 0;
for (int ss=oldchain.size()-1; ss >= 0; ss--){
if (skip_jsr < 0){
throw new AssertionViolatedException("More RET than JSR in execution chain?!");
}
//System.err.println("+"+oldchain.get(ss));
if (oldchain.get(ss).getInstruction().getInstruction().isJsrInstruction()) {
if (skip_jsr == 0){
lastJSR = oldchain.get(ss);
break;
}
else{
skip_jsr--;
}
}
if (oldchain.get(ss).getInstruction().getInstruction() instanceof RET){
skip_jsr++;
}
}
if (lastJSR == null){
throw new AssertionViolatedException("RET without a JSR before in ExecutionChain?! EC: '"+oldchain+"'.");
}
InstructionBranch jsr = (InstructionBranch) (lastJSR.getInstruction().getInstruction());
if ( theSuccessor != (cfg.contextOf(jsr.physicalSuccessor())) ){
throw new AssertionViolatedException("RET '"+u.getInstruction()+"' info inconsistent: jump back to '"+theSuccessor+"' or '"+cfg.contextOf(jsr.physicalSuccessor())+"'?");
}
if (theSuccessor.execute(u.getOutFrame(oldchain), newchain, icv, ev)){
icq.add(theSuccessor, (ArrayList<InstructionContext>) newchain.clone());
}
}
else{// "not a ret"
// Normal successors. Add them to the queue of successors.
InstructionContext[] succs = u.getSuccessors();
for (int s=0; s<succs.length; s++){
InstructionContext v = succs[s];
if (v.execute(u.getOutFrame(oldchain), newchain, icv, ev)){
icq.add(v, (ArrayList<InstructionContext>) newchain.clone());
}
}
}// end "not a ret"

// Exception Handlers. Add them to the queue of successors.
// [subroutines are never protected; mandated by JustIce]
ExceptionHandler[] exc_hds = u.getExceptionHandlers();
for (int s=0; s<exc_hds.length; s++){
InstructionContext v = cfg.contextOf(exc_hds[s].getHandlerStart());
// TODO: the "oldchain" and "newchain" is used to determine the subroutine
// we're in (by searching for the last JSR) by the InstructionContext
// implementation. Therefore, we should not use this chain mechanism
// when dealing with exception handlers.
// Example: a JSR with an exception handler as its successor does not
// mean we're in a subroutine if we go to the exception handler.
// We should address this problem later; by now we simply "cut" the chain
// by using an empty chain for the exception handlers.
//if (v.execute(new Frame(u.getOutFrame(oldchain).getLocals(), new OperandStack (u.getOutFrame().getStack().maxStack(), (exc_hds[s].getExceptionType()==null? Type.THROWABLE : exc_hds[s].getExceptionType())) ), newchain), icv, ev){
//icq.add(v, (ArrayList) newchain.clone());
if (v.execute(new Frame(u.getOutFrame(oldchain).getLocals(), new OperandStack (u.getOutFrame(oldchain).getStack().maxStack(), (exc_hds[s].getExceptionType()==null? Type.THROWABLE : exc_hds[s].getExceptionType())) ), new ArrayList<InstructionContext>(), icv, ev)){
icq.add(v, new ArrayList<InstructionContext>());
}
}

}// while (!icq.isEmpty()) END
InstructionHandle ih = start.getInstruction();
do{
if ((ih.getInstruction().isReturnInstruction()) && (!(cfg.isDead(ih)))) {
InstructionContext ic = cfg.contextOf(ih);
Frame f = ic.getOutFrame(new ArrayList<InstructionContext>()); // TODO: This is buggy, we check only the top-level return instructions this way. Maybe some maniac returns from a method when in a subroutine?
LocalVariables lvs = f.getLocals();
for (int i=0; i<lvs.maxLocals(); i++){
if (lvs.get(i) instanceof UninitializedObjectType){
this.addMessage("Warning: ReturnInstruction '"+ic+"' may leave method with an uninitialized object in the local variables array '"+lvs+"'.");
}
}
OperandStack os = f.getStack();
for (int i=0; i<os.size(); i++){
if (os.peek(i) instanceof UninitializedObjectType){
this.addMessage("Warning: ReturnInstruction '"+ic+"' may leave method with an uninitialized object on the operand stack '"+os+"'.");
}
}
}
}while ((ih = ih.getNext()) != null);
}

/**
* Pass 3b implements the data flow analysis as described in the Java Virtual
* Machine Specification, Second Edition.
* Later versions will use LocalVariablesInfo objects to verify if the
* verifier-inferred types and the class file's debug information (LocalVariables
* attributes) match [TODO].
*
* @see org.aspectj.apache.bcel.verifier.statics.LocalVariablesInfo
* @see org.aspectj.apache.bcel.verifier.statics.Pass2Verifier#getLocalVariablesInfo(int)
*/
public VerificationResult do_verify(){
if (! myOwner.doPass3a(method_no).equals(VerificationResult.VR_OK)){
return VerificationResult.VR_NOTYET;
}

// Pass 3a ran before, so it's safe to assume the JavaClass object is
// in the BCEL repository.
JavaClass jc = Repository.lookupClass(myOwner.getClassName());

ConstantPool constantPoolGen = new ConstantPool(jc.getConstantPool().getConstantPool());
// Init Visitors
InstConstraintVisitor icv = new InstConstraintVisitor();
icv.setConstantPoolGen(constantPoolGen);
ExecutionVisitor ev = new ExecutionVisitor();
ev.setConstantPoolGen(constantPoolGen);
Method[] methods = jc.getMethods(); // Method no "method_no" exists, we ran Pass3a before on it!

try{

MethodGen mg = new MethodGen(methods[method_no], myOwner.getClassName(), constantPoolGen);

icv.setMethodGen(mg);
////////////// DFA BEGINS HERE ////////////////
if (! (mg.isAbstract() || mg.isNative()) ){ // IF mg HAS CODE (See pass 2)
ControlFlowGraph cfg = new ControlFlowGraph(mg);

// Build the initial frame situation for this method.
Frame f = new Frame(mg.getMaxLocals(),mg.getMaxStack());
if ( !mg.isStatic() ){
if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)){
Frame._this = new UninitializedObjectType(new ObjectType(jc.getClassName()));
f.getLocals().set(0, Frame._this);
}
else{
Frame._this = null;
f.getLocals().set(0, new ObjectType(jc.getClassName()));
}
}
Type[] argtypes = mg.getArgumentTypes();
int twoslotoffset = 0;
for (int j=0; j<argtypes.length; j++){
if (argtypes[j] == Type.SHORT || argtypes[j] == Type.BYTE || argtypes[j] == Type.CHAR || argtypes[j] == Type.BOOLEAN){
argtypes[j] = Type.INT;
}
f.getLocals().set(twoslotoffset + j + (mg.isStatic()?0:1), argtypes[j]);
if (argtypes[j].getSize() == 2){
twoslotoffset++;
f.getLocals().set(twoslotoffset + j + (mg.isStatic()?0:1), Type.UNKNOWN);
}
}
circulationPump(cfg, cfg.contextOf(mg.getInstructionList().getStart()), f, icv, ev);
}
}
catch (VerifierConstraintViolatedException ce){
ce.extendMessage("Constraint violated in method '"+methods[method_no]+"':\n","");
return new VerificationResult(VerificationResult.VERIFIED_REJECTED, ce.getMessage());
}
catch (RuntimeException re){
// These are internal errors

StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
re.printStackTrace(pw);

throw new AssertionViolatedException("Some RuntimeException occured while verify()ing class '"+jc.getClassName()+"', method '"+methods[method_no]+"'. Original RuntimeException's stack trace:\n---\n"+sw+"---\n");
}
return VerificationResult.VR_OK;
}

/** Returns the method number as supplied when instantiating. */
public int getMethodNo(){
return method_no;
}
}

+ 0
- 126
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutine.java View File

@@ -1,126 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.generic.*;

/**
* This interface defines properties of JVM bytecode subroutines.
* Note that it is 'abused' to maintain the top-level code in a
* consistent fashion, too.
*
* @version $Id: Subroutine.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public interface Subroutine{
/**
* Returns all the JsrInstructions that have the
* first instruction of this subroutine as their target.
* <B>Must not be invoked on the 'top-level subroutine'.</B>
*/
public InstructionHandle[] getEnteringJsrInstructions();
/**
* Returns the one and only RET that leaves the subroutine.
* Note that JustIce has a pretty rigid notion of a subroutine.
* <B>Must not be invoked on the 'top-level subroutine'.</B>
*
* @see org.aspectj.apache.bcel.verifier.structurals.Subroutines
*/
public InstructionHandle getLeavingRET();

/**
* Returns all instructions that together form this subroutine.
* Note that an instruction is part of exactly one subroutine
* (the top-level code is considered to be a special subroutine) -
* else it is not reachable at all (dead code).
*/
public InstructionHandle[] getInstructions();

/**
* Returns if the given InstructionHandle refers to an instruction
* that is part of this subroutine. This is a convenience method
* that saves iteration over the InstructionHandle objects returned
* by getInstructions().
*
* @see #getInstructions()
*/
public boolean contains(InstructionHandle inst);

/**
* Returns an int[] containing the indices of the local variable slots
* accessed by this Subroutine (read-accessed, write-accessed or both);
* local variables referenced by subroutines of this subroutine are
* not included.
*
* @see #getRecursivelyAccessedLocalsIndices()
*/
public int[] getAccessedLocalsIndices();

/**
* Returns an int[] containing the indices of the local variable slots
* accessed by this Subroutine (read-accessed, write-accessed or both);
* local variables referenced by subroutines of this subroutine are
* included.
*
* @see #getAccessedLocalsIndices()
*/
public int[] getRecursivelyAccessedLocalsIndices();
/**
* Returns the subroutines that are directly called from this subroutine.
*/
public Subroutine[] subSubs();
}

+ 0
- 670
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutines.java View File

@@ -1,670 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.generic.*;
import org.aspectj.apache.bcel.verifier.exc.*;
import java.awt.Color;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;

/**
* Instances of this class contain information about the subroutines
* found in a code array of a method.
* This implementation considers the top-level (the instructions
* reachable without a JSR or JSR_W starting off from the first
* instruction in a code array of a method) being a special subroutine;
* see getTopLevel() for that.
* Please note that the definition of subroutines in the Java Virtual
* Machine Specification, Second Edition is somewhat incomplete.
* Therefore, JustIce uses an own, more rigid notion.
* Basically, a subroutine is a piece of code that starts at the target
* of a JSR of JSR_W instruction and ends at a corresponding RET
* instruction. Note also that the control flow of a subroutine
* may be complex and non-linear; and that subroutines may be nested.
* JustIce also mandates subroutines not to be protected by exception
* handling code (for the sake of control flow predictability).
* To understand JustIce's notion of subroutines, please read
*
* TODO: refer to the paper.
*
* @version $Id: Subroutines.java,v 1.4 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see #getTopLevel()
*/
public class Subroutines{
/**
* This inner class implements the Subroutine interface.
*/
private class SubroutineImpl implements Subroutine{
/**
* UNSET, a symbol for an uninitialized localVariable
* field. This is used for the "top-level" Subroutine;
* i.e. no subroutine.
*/
private final static int UNSET = -1;

/**
* The Local Variable slot where the first
* instruction of this subroutine (an ASTORE) stores
* the JsrInstruction's ReturnAddress in and
* the RET of this subroutine operates on.
*/
private int localVariable = UNSET;

/** The instructions that belong to this subroutine. */
private HashSet<Serializable> instructions = new HashSet<Serializable>(); // Elements: InstructionHandle

/*
* Refer to the Subroutine interface for documentation.
*/
public boolean contains(InstructionHandle inst){
return instructions.contains(inst);
}

/**
* The JSR or JSR_W instructions that define this
* subroutine by targeting it.
*/
private HashSet<InstructionHandle> theJSRs = new HashSet<InstructionHandle>();

/**
* The RET instruction that leaves this subroutine.
*/
private InstructionHandle theRET;

/**
* Returns a String representation of this object, merely
* for debugging purposes.
* (Internal) Warning: Verbosity on a problematic subroutine may cause
* stack overflow errors due to recursive subSubs() calls.
* Don't use this, then.
*/
public String toString(){
String ret = "Subroutine: Local variable is '"+localVariable+"', JSRs are '"+theJSRs+"', RET is '"+theRET+"', Instructions: '"+instructions.toString()+"'.";

ret += " Accessed local variable slots: '";
int[] alv = getAccessedLocalsIndices();
for (int i=0; i<alv.length; i++){
ret += alv[i]+" ";
}
ret+="'.";

ret += " Recursively (via subsub...routines) accessed local variable slots: '";
alv = getRecursivelyAccessedLocalsIndices();
for (int i=0; i<alv.length; i++){
ret += alv[i]+" ";
}
ret+="'.";

return ret;
}

/**
* Sets the leaving RET instruction. Must be invoked after all instructions are added.
* Must not be invoked for top-level 'subroutine'.
*/
void setLeavingRET(){
if (localVariable == UNSET){
throw new AssertionViolatedException("setLeavingRET() called for top-level 'subroutine' or forgot to set local variable first.");
}
Iterator<Serializable> iter = instructions.iterator();
InstructionHandle ret = null;
while(iter.hasNext()){
InstructionHandle actual = (InstructionHandle) iter.next();
if (actual.getInstruction() instanceof RET){
if (ret != null){
throw new StructuralCodeConstraintException("Subroutine with more then one RET detected: '"+ret+"' and '"+actual+"'.");
}
else{
ret = actual;
}
}
}
if (ret == null){
throw new StructuralCodeConstraintException("Subroutine without a RET detected.");
}
if (((RET) ret.getInstruction()).getIndex() != localVariable){
throw new StructuralCodeConstraintException("Subroutine uses '"+ret+"' which does not match the correct local variable '"+localVariable+"'.");
}
theRET = ret;
}

/*
* Refer to the Subroutine interface for documentation.
*/
public InstructionHandle[] getEnteringJsrInstructions(){
if (this == TOPLEVEL) {
throw new AssertionViolatedException("getLeavingRET() called on top level pseudo-subroutine.");
}
InstructionHandle[] jsrs = new InstructionHandle[theJSRs.size()];
return (theJSRs.toArray(jsrs));
}

/**
* Adds a new JSR or JSR_W that has this subroutine as its target.
*/
public void addEnteringJsrInstruction(InstructionHandle jsrInst){
if ( (jsrInst == null) || (! (jsrInst.getInstruction().isJsrInstruction()))){
throw new AssertionViolatedException("Expecting JsrInstruction InstructionHandle.");
}
if (localVariable == UNSET){
throw new AssertionViolatedException("Set the localVariable first!");
}
else{
// Something is wrong when an ASTORE is targeted that does not operate on the same local variable than the rest of the
// JsrInstruction-targets and the RET.
// (We don't know out leader here so we cannot check if we're really targeted!)
if (localVariable != ( (((InstructionBranch) jsrInst.getInstruction()).getTarget().getInstruction())).getIndex()){
throw new AssertionViolatedException("Setting a wrong JsrInstruction.");
}
}
theJSRs.add(jsrInst);
}

/*
* Refer to the Subroutine interface for documentation.
*/
public InstructionHandle getLeavingRET(){
if (this == TOPLEVEL) {
throw new AssertionViolatedException("getLeavingRET() called on top level pseudo-subroutine.");
}
return theRET;
}

/*
* Refer to the Subroutine interface for documentation.
*/
public InstructionHandle[] getInstructions(){
InstructionHandle[] ret = new InstructionHandle[instructions.size()];
return instructions.toArray(ret);
}

/*
* Adds an instruction to this subroutine.
* All instructions must have been added before invoking setLeavingRET().
* @see #setLeavingRET
*/
void addInstruction(InstructionHandle ih){
if (theRET != null){
throw new AssertionViolatedException("All instructions must have been added before invoking setLeavingRET().");
}
instructions.add(ih);
}

/* Satisfies Subroutine.getRecursivelyAccessedLocalsIndices(). */
public int[] getRecursivelyAccessedLocalsIndices(){
HashSet<Integer> s = new HashSet<Integer>();
int[] lvs = getAccessedLocalsIndices();
for (int j=0; j<lvs.length; j++){
s.add(new Integer(lvs[j]));
}
_getRecursivelyAccessedLocalsIndicesHelper(s, this.subSubs());
int[] ret = new int[s.size()];
Iterator<Integer> i = s.iterator();
int j=-1;
while (i.hasNext()){
j++;
ret[j] = i.next().intValue();
}
return ret;
}

/**
* A recursive helper method for getRecursivelyAccessedLocalsIndices().
* @see #getRecursivelyAccessedLocalsIndices()
*/
private void _getRecursivelyAccessedLocalsIndicesHelper(HashSet<Integer> s, Subroutine[] subs){
for (int i=0; i<subs.length; i++){
int[] lvs = subs[i].getAccessedLocalsIndices();
for (int j=0; j<lvs.length; j++){
s.add(new Integer(lvs[j]));
}
if(subs[i].subSubs().length != 0){
_getRecursivelyAccessedLocalsIndicesHelper(s, subs[i].subSubs());
}
}
}

/*
* Satisfies Subroutine.getAccessedLocalIndices().
*/
public int[] getAccessedLocalsIndices(){
//TODO: Implement caching.
HashSet<Serializable> acc = new HashSet<Serializable>();
if (theRET == null && this != TOPLEVEL){
throw new AssertionViolatedException("This subroutine object must be built up completely before calculating accessed locals.");
}
Iterator<Serializable> i = instructions.iterator();
while (i.hasNext()){
InstructionHandle ih = (InstructionHandle) i.next();
// RET is not a LocalVariableInstruction in the current version of BCEL.
if (ih.getInstruction() instanceof InstructionLV || ih.getInstruction() instanceof RET){
int idx = ((ih.getInstruction())).getIndex();
acc.add(new Integer(idx));
// LONG? DOUBLE?.
try{
// LocalVariableInstruction instances are typed without the need to look into
// the constant pool.
if (ih.getInstruction() instanceof InstructionLV){
int s = ((InstructionLV) ih.getInstruction()).getType(null).getSize();
if (s==2) acc.add(new Integer(idx+1));
}
}
catch(RuntimeException re){
throw new AssertionViolatedException("Oops. BCEL did not like NULL as a ConstantPoolGen object.");
}
}
}

int[] ret = new int[acc.size()];
i = acc.iterator();
int j=-1;
while (i.hasNext()){
j++;
ret[j] = ((Integer) i.next()).intValue();
}
return ret;
}

/*
* Satisfies Subroutine.subSubs().
*/
public Subroutine[] subSubs(){
HashSet<Subroutine> h = new HashSet<Subroutine>();

Iterator<Serializable> i = instructions.iterator();
while (i.hasNext()){
Instruction inst = ((InstructionHandle) i.next()).getInstruction();
if (inst.isJsrInstruction()){
InstructionHandle targ = ((InstructionBranch) inst).getTarget();
h.add(getSubroutine(targ));
}
}
Subroutine[] ret = new Subroutine[h.size()];
return h.toArray(ret);
}

/*
* Sets the local variable slot the ASTORE that is targeted
* by the JsrInstructions of this subroutine operates on.
* This subroutine's RET operates on that same local variable
* slot, of course.
*/
void setLocalVariable(int i){
if (localVariable != UNSET){
throw new AssertionViolatedException("localVariable set twice.");
}
else{
localVariable = i;
}
}

/**
* The default constructor.
*/
public SubroutineImpl(){
}

}// end Inner Class SubrouteImpl

/**
* The Hashtable containing the subroutines found.
* Key: InstructionHandle of the leader of the subroutine.
* Elements: SubroutineImpl objects.
*/
private Hashtable<InstructionHandle, Subroutine> subroutines = new Hashtable<InstructionHandle, Subroutine>();

/**
* This is referring to a special subroutine, namely the
* top level. This is not really a subroutine but we use
* it to distinguish between top level instructions and
* unreachable instructions.
*/
public final Subroutine TOPLEVEL;

/**
* Constructor.
* @param il A MethodGen object representing method to
* create the Subroutine objects of.
*/
public Subroutines(MethodGen mg){

InstructionHandle[] all = mg.getInstructionList().getInstructionHandles();
CodeExceptionGen[] handlers = mg.getExceptionHandlers();

// Define our "Toplevel" fake subroutine.
TOPLEVEL = new SubroutineImpl();

// Calculate "real" subroutines.
HashSet<InstructionHandle> sub_leaders = new HashSet<InstructionHandle>(); // Elements: InstructionHandle
InstructionHandle ih = all[0];
for (int i=0; i<all.length; i++){
Instruction inst = all[i].getInstruction();
if (inst.isJsrInstruction()){
sub_leaders.add(((InstructionBranch) inst).getTarget());
}
}

// Build up the database.
Iterator<InstructionHandle> iter = sub_leaders.iterator();
while (iter.hasNext()){
SubroutineImpl sr = new SubroutineImpl();
InstructionHandle astore = (iter.next());
sr.setLocalVariable( ( (astore.getInstruction())).getIndex() );
subroutines.put(astore, sr);
}

// Fake it a bit. We want a virtual "TopLevel" subroutine.
subroutines.put(all[0], TOPLEVEL);
sub_leaders.add(all[0]);

// Tell the subroutines about their JsrInstructions.
// Note that there cannot be a JSR targeting the top-level
// since "Jsr 0" is disallowed in Pass 3a.
// Instructions shared by a subroutine and the toplevel are
// disallowed and checked below, after the BFS.
for (int i=0; i<all.length; i++){
Instruction inst = all[i].getInstruction();
if (inst.isJsrInstruction()){
InstructionHandle leader = ((InstructionBranch) inst).getTarget();
((SubroutineImpl) getSubroutine(leader)).addEnteringJsrInstruction(all[i]);
}
}

// Now do a BFS from every subroutine leader to find all the
// instructions that belong to a subroutine.
HashSet<InstructionHandle> instructions_assigned = new HashSet<InstructionHandle>(); // we don't want to assign an instruction to two or more Subroutine objects.

Hashtable<InstructionHandle, Color> colors = new Hashtable<InstructionHandle, Color>(); //Graph colouring. Key: InstructionHandle, Value: java.awt.Color .

iter = sub_leaders.iterator();
while (iter.hasNext()){
// Do some BFS with "actual" as the root of the graph.
InstructionHandle actual = (iter.next());
// Init colors
for (int i=0; i<all.length; i++){
colors.put(all[i], Color.white);
}
colors.put(actual, Color.gray);
// Init Queue
ArrayList<InstructionHandle> Q = new ArrayList<InstructionHandle>();
Q.add(actual); // add(Obj) adds to the end, remove(0) removes from the start.

/* BFS ALGORITHM MODIFICATION: Start out with multiple "root" nodes, as exception handlers are starting points of top-level code, too. [why top-level? TODO: Refer to the special JustIce notion of subroutines.]*/
if (actual == all[0]){
for (int j=0; j<handlers.length; j++){
colors.put(handlers[j].getHandlerPC(), Color.gray);
Q.add(handlers[j].getHandlerPC());
}
}
/* CONTINUE NORMAL BFS ALGORITHM */

// Loop until Queue is empty
while (Q.size() != 0){
InstructionHandle u = Q.remove(0);
InstructionHandle[] successors = getSuccessors(u);
for (int i=0; i<successors.length; i++){
if (colors.get(successors[i]) == Color.white){
colors.put(successors[i], Color.gray);
Q.add(successors[i]);
}
}
colors.put(u, Color.black);
}
// BFS ended above.
for (int i=0; i<all.length; i++){
if (colors.get(all[i]) == Color.black){
((SubroutineImpl) (actual==all[0]?getTopLevel():getSubroutine(actual))).addInstruction(all[i]);
if (instructions_assigned.contains(all[i])){
throw new StructuralCodeConstraintException("Instruction '"+all[i]+"' is part of more than one subroutine (or of the top level and a subroutine).");
}
else{
instructions_assigned.add(all[i]);
}
}
}
if (actual != all[0]){// If we don't deal with the top-level 'subroutine'
((SubroutineImpl) getSubroutine(actual)).setLeavingRET();
}
}

// Now make sure no instruction of a Subroutine is protected by exception handling code
// as is mandated by JustIces notion of subroutines.
for (int i=0; i<handlers.length; i++){
InstructionHandle _protected = handlers[i].getStartPC();
while (_protected != handlers[i].getEndPC().getNext()){// Note the inclusive/inclusive notation of "generic API" exception handlers!
Enumeration<Subroutine> subs = subroutines.elements();
while (subs.hasMoreElements()){
Subroutine sub = subs.nextElement();
if (sub != subroutines.get(all[0])){ // We don't want to forbid top-level exception handlers.
if (sub.contains(_protected)){
throw new StructuralCodeConstraintException("Subroutine instruction '"+_protected+"' is protected by an exception handler, '"+handlers[i]+"'. This is forbidden by the JustIce verifier due to its clear definition of subroutines.");
}
}
}
_protected = _protected.getNext();
}
}

// Now make sure no subroutine is calling a subroutine
// that uses the same local variable for the RET as themselves
// (recursively).
// This includes that subroutines may not call themselves
// recursively, even not through intermediate calls to other
// subroutines.
noRecursiveCalls(getTopLevel(), new HashSet<Integer>());

}

/**
* This (recursive) utility method makes sure that
* no subroutine is calling a subroutine
* that uses the same local variable for the RET as themselves
* (recursively).
* This includes that subroutines may not call themselves
* recursively, even not through intermediate calls to other
* subroutines.
*
* @throws StructuralCodeConstraintException if the above constraint is not satisfied.
*/
private void noRecursiveCalls(Subroutine sub, HashSet<Integer> set){
Subroutine[] subs = sub.subSubs();

for (int i=0; i<subs.length; i++){
int index = ((RET) (subs[i].getLeavingRET().getInstruction())).getIndex();

if (!set.add(new Integer(index))){
// Don't use toString() here because of possibly infinite recursive subSubs() calls then.
SubroutineImpl si = (SubroutineImpl) subs[i];
throw new StructuralCodeConstraintException("Subroutine with local variable '"+si.localVariable+"', JSRs '"+si.theJSRs+"', RET '"+si.theRET+"' is called by a subroutine which uses the same local variable index as itself; maybe even a recursive call? JustIce's clean definition of a subroutine forbids both.");
}

noRecursiveCalls(subs[i], set);

set.remove(new Integer(index));
}
}

/**
* Returns the Subroutine object associated with the given
* leader (that is, the first instruction of the subroutine).
* You must not use this to get the top-level instructions
* modeled as a Subroutine object.
*
* @see #getTopLevel()
*/
public Subroutine getSubroutine(InstructionHandle leader){
Subroutine ret = subroutines.get(leader);

if (ret == null){
throw new AssertionViolatedException("Subroutine requested for an InstructionHandle that is not a leader of a subroutine.");
}

if (ret == TOPLEVEL){
throw new AssertionViolatedException("TOPLEVEL special subroutine requested; use getTopLevel().");
}

return ret;
}

/**
* Returns the subroutine object associated with the
* given instruction. This is a costly operation, you
* should consider using getSubroutine(InstructionHandle).
* Returns 'null' if the given InstructionHandle lies
* in so-called 'dead code', i.e. code that can never
* be executed.
*
* @see #getSubroutine(InstructionHandle)
* @see #getTopLevel()
*/
public Subroutine subroutineOf(InstructionHandle any){
Iterator<Subroutine> i = subroutines.values().iterator();
while (i.hasNext()){
Subroutine s = i.next();
if (s.contains(any)) return s;
}
System.err.println("DEBUG: Please verify '"+any+"' lies in dead code.");
return null;
//throw new AssertionViolatedException("No subroutine for InstructionHandle found (DEAD CODE?).");
}

/**
* For easy handling, the piece of code that is <B>not</B> a
* subroutine, the top-level, is also modeled as a Subroutine
* object.
* It is a special Subroutine object where <B>you must not invoke
* getEnteringJsrInstructions() or getLeavingRET()</B>.
*
* @see Subroutine#getEnteringJsrInstructions()
* @see Subroutine#getLeavingRET()
*/
public Subroutine getTopLevel(){
return TOPLEVEL;
}
/**
* A utility method that calculates the successors of a given InstructionHandle
* <B>in the same subroutine</B>. That means, a RET does not have any successors
* as defined here. A JsrInstruction has its physical successor as its successor
* (opposed to its target) as defined here.
*/
private static InstructionHandle[] getSuccessors(InstructionHandle instruction){
final InstructionHandle[] empty = new InstructionHandle[0];
final InstructionHandle[] single = new InstructionHandle[1];
final InstructionHandle[] pair = new InstructionHandle[2];

Instruction inst = instruction.getInstruction();

if (inst instanceof RET){
return empty;
}

// Terminates method normally.
if (inst.isReturnInstruction()){
return empty;
}

// Terminates method abnormally, because JustIce mandates
// subroutines not to be protected by exception handlers.
if (inst.getOpcode()==Constants.ATHROW){
return empty;
}

// See method comment.
if (inst.isJsrInstruction()){
single[0] = instruction.getNext();
return single;
}

if (inst.getOpcode()==Constants.GOTO || inst.getOpcode()==Constants.GOTO_W){
single[0] = ((InstructionBranch) inst).getTarget();
return single;
}

if (inst instanceof InstructionBranch){
if (inst instanceof InstructionSelect){
// BCEL's getTargets() returns only the non-default targets,
// thanks to Eli Tilevich for reporting.
InstructionHandle[] matchTargets = ((InstructionSelect) inst).getTargets();
InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1];
ret[0] = ((InstructionSelect) inst).getTarget();
System.arraycopy(matchTargets, 0, ret, 1, matchTargets.length);
return ret;
}
else{
pair[0] = instruction.getNext();
pair[1] = ((InstructionBranch) inst).getTarget();
return pair;
}
}

// default case: Fall through.
single[0] = instruction.getNext();
return single;
}

/**
* Returns a String representation of this object; merely for debugging puposes.
*/
public String toString(){
return "---\n"+subroutines.toString()+"\n---\n";
}
}

+ 0
- 97
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/UninitializedObjectType.java View File

@@ -1,97 +0,0 @@
package org.aspectj.apache.bcel.verifier.structurals;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import org.aspectj.apache.bcel.*;
import org.aspectj.apache.bcel.generic.*;

/**
* This class represents an uninitialized object type; see The Java
* Virtual Machine Specification, Second Edition, page 147: 4.9.4 for
* more details.
*
* @version $Id: UninitializedObjectType.java,v 1.2 2008/05/28 23:53:03 aclement Exp $
* @author <A HREF="https://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class UninitializedObjectType extends ReferenceType implements Constants{

/** The "initialized" version. */
private ObjectType initialized;

/** Creates a new instance. */
public UninitializedObjectType(ObjectType t){
super(T_UNKNOWN, "<UNINITIALIZED OBJECT OF TYPE '"+t.getClassName()+"'>");
initialized = t;
}

/**
* Returns the ObjectType of the same class as the one of the uninitialized object
* represented by this UninitializedObjectType instance.
*/
public ObjectType getInitialized(){
return initialized;
}

/**
* Returns true on equality of this and o.
* Equality means the ObjectType instances of "initialized"
* equal one another in this and the o instance.
*
*/
public boolean equals(Object o){
if (! (o instanceof UninitializedObjectType)) return false;
return initialized.equals(((UninitializedObjectType)o).initialized);
}
}

+ 0
- 27
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/package.html View File

@@ -1,27 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
$Id: package.html,v 1.2 2008/05/28 23:53:02 aclement Exp $
-->
</head>
<body bgcolor="white">

Provides a PassVerifier class mostly used internally by JustIce, yielding a control flow graph for public use as
a nice side effect.

<h2>Package Specification</h2>

Contained in this package is a PassVerifier class for use with the JustIce verifier and its utility classes.
Only the pass performing what Sun calls "Structural Constraints on Java Virtual Machine Code"
has a PassVerifier class here. JustIce calls this pass "Pass 3b".

<h2>Related Documentation</h2>

For a simple demonstration of JustIce working, please see:
<ul>
<li><a href="https://www.inf.fu-berlin.de/~ehaase/cgi-html/Verifier.html">A WWW front-end for JustIce.</a>
</ul>

</body>
</html>

+ 0
- 366
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELFactory.java View File

@@ -1,366 +0,0 @@
package org.aspectj.apache.bcel.verifier.util;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.Utility;
import org.aspectj.apache.bcel.generic.BranchHandle;
import org.aspectj.apache.bcel.generic.CodeExceptionGen;
import org.aspectj.apache.bcel.generic.FieldInstruction;
import org.aspectj.apache.bcel.generic.IINC;
import org.aspectj.apache.bcel.generic.Instruction;
import org.aspectj.apache.bcel.generic.InstructionBranch;
import org.aspectj.apache.bcel.generic.InstructionByte;
import org.aspectj.apache.bcel.generic.InstructionCP;
import org.aspectj.apache.bcel.generic.InstructionConstants;
import org.aspectj.apache.bcel.generic.InstructionHandle;
import org.aspectj.apache.bcel.generic.InstructionSelect;
import org.aspectj.apache.bcel.generic.InvokeInstruction;
import org.aspectj.apache.bcel.generic.MULTIANEWARRAY;
import org.aspectj.apache.bcel.generic.MethodGen;
import org.aspectj.apache.bcel.generic.ObjectType;
import org.aspectj.apache.bcel.generic.RET;
import org.aspectj.apache.bcel.generic.Type;
import org.aspectj.apache.bcel.verifier.InstructionWalker;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

/**
* Factory creates il.append() statements, and sets instruction targets. A helper class for BCELifier.
*
* @see BCELifier
* @version $Id: BCELFactory.java,v 1.6 2009/09/14 20:29:10 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
class BCELFactory extends org.aspectj.apache.bcel.verifier.EmptyInstVisitor {
private final MethodGen _mg;
private final PrintWriter _out;
private final ConstantPool _cp;

BCELFactory(MethodGen mg, PrintWriter out) {
_mg = mg;
_cp = mg.getConstantPool();
_out = out;
}

private final HashMap<Instruction, InstructionHandle> branch_map = new HashMap<Instruction, InstructionHandle>(); // Map<Instruction,
// InstructionHandle>

public void start() {
if (!_mg.isAbstract() && !_mg.isNative()) {
for (InstructionHandle ih = _mg.getInstructionList().getStart(); ih != null; ih = ih.getNext()) {
Instruction i = ih.getInstruction();

if (i instanceof InstructionBranch) {
branch_map.put(i, ih); // memorize container
}

if (ih.hasTargeters()) {
if (i instanceof InstructionBranch) {
_out.println(" InstructionHandle ih_" + ih.getPosition() + ";");
} else {
_out.print(" InstructionHandle ih_" + ih.getPosition() + " = ");
}
} else {
_out.print(" ");
}

if (!visitInstruction(i)) {
InstructionWalker.accept(i, this);
}
}

updateBranchTargets();
updateExceptionHandlers();
}
}

private boolean visitInstruction(Instruction i) {
short opcode = i.getOpcode();

if (InstructionConstants.INSTRUCTIONS[opcode] != null && !i.isConstantInstruction() && !i.isReturnInstruction()) { // Handled
// below
_out.println("il.append(InstructionConstants." + i.getName().toUpperCase() + ");");
return true;
}

return false;
}

public void visitLocalVariableInstruction(Instruction i) {
short opcode = i.getOpcode();
Type type = i.getType(_cp);

if (opcode == Constants.IINC) {
_out.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC) i).getIncrement() + "));");
} else {
String kind = opcode < Constants.ISTORE ? "Load" : "Store";
_out.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type) + ", " + i.getIndex() + "));");
}
}

@Override
public void visitArrayInstruction(Instruction i) {
short opcode = i.getOpcode();
Type type = i.getType(_cp);
String kind = opcode < Constants.IASTORE ? "Load" : "Store";

_out.println("il.append(_factory.createArray" + kind + "(" + BCELifier.printType(type) + "));");
}

public void visitFieldInstruction(FieldInstruction i) {
short opcode = i.getOpcode();

String class_name = i.getClassName(_cp);
String field_name = i.getFieldName(_cp);
Type type = i.getFieldType(_cp);

_out.println("il.append(_factory.createFieldAccess(\"" + class_name + "\", \"" + field_name + "\", "
+ BCELifier.printType(type) + ", " + "Constants." + Constants.OPCODE_NAMES[opcode].toUpperCase() + "));");
}

@Override
public void visitInvokeInstruction(InvokeInstruction i) {
short opcode = i.getOpcode();
String class_name = i.getClassName(_cp);
String method_name = i.getMethodName(_cp);
Type type = i.getReturnType(_cp);
Type[] arg_types = i.getArgumentTypes(_cp);

_out.println("il.append(_factory.createInvoke(\"" + class_name + "\", \"" + method_name + "\", "
+ BCELifier.printType(type) + ", " + BCELifier.printArgumentTypes(arg_types) + ", " + "Constants."
+ Constants.OPCODE_NAMES[opcode].toUpperCase() + "));");
}

@Override
public void visitAllocationInstruction(Instruction i) {
Type type;

if (i.isConstantPoolInstruction()) {
type = ((InstructionCP) i).getType(_cp);
} else {
type = ((InstructionByte) i).getType();
}

short opcode = i.getOpcode();
int dim = 1;

switch (opcode) {
case Constants.NEW:
_out.println("il.append(_factory.createNew(\"" + ((ObjectType) type).getClassName() + "\"));");
break;

case Constants.MULTIANEWARRAY:
dim = ((MULTIANEWARRAY) i).getDimensions();
case Constants.ANEWARRAY:
case Constants.NEWARRAY:
_out.println("il.append(_factory.createNewArray(" + BCELifier.printType(type) + ", (short) " + dim + "));");
break;

default:
throw new RuntimeException("Oops: " + opcode);
}
}

private void createConstant(Object value) {
String embed = value.toString();

if (value instanceof String) {
embed = '"' + Utility.convertString(value.toString()) + '"';
} else if (value instanceof Character) {
embed = "(char)0x" + Integer.toHexString(((Character) value).charValue());
}

_out.println("il.append(new PUSH(_cp, " + embed + "));");
}

@Override
public void visitLDC(Instruction i) {
createConstant(i.getValue(_cp));
}

@Override
public void visitLDC2_W(Instruction i) {
createConstant(i.getValue(_cp));
}

@Override
public void visitConstantPushInstruction(Instruction i) {
createConstant(i.getValue());
}

@Override
public void visitINSTANCEOF(Instruction i) {
Type type = i.getType(_cp);

_out.println("il.append(new INSTANCEOF(_cp.addClass(" + BCELifier.printType(type) + ")));");
}

@Override
public void visitCHECKCAST(Instruction i) {
Type type = i.getType(_cp);

_out.println("il.append(_factory.createCheckCast(" + BCELifier.printType(type) + "));");
}

@Override
public void visitReturnInstruction(Instruction i) {
Type type = i.getType(_cp);

_out.println("il.append(_factory.createReturn(" + BCELifier.printType(type) + "));");
}

// Memorize BranchInstructions that need an update
private final ArrayList<InstructionBranch> branches = new ArrayList<InstructionBranch>();

@Override
public void visitBranchInstruction(InstructionBranch bi) {
BranchHandle bh = (BranchHandle) branch_map.get(bi);
int pos = bh.getPosition();
String name = bi.getName() + "_" + pos;

if (bi instanceof InstructionSelect) {
InstructionSelect s = (InstructionSelect) bi;
branches.add(bi);

StringBuffer args = new StringBuffer("new int[] { ");
int[] matchs = s.getMatchs();

for (int i = 0; i < matchs.length; i++) {
args.append(matchs[i]);

if (i < matchs.length - 1) {
args.append(", ");
}
}

args.append(" }");

_out.print(" Select " + name + " = new " + bi.getName().toUpperCase() + "(" + args + ", new InstructionHandle[] { ");

for (int i = 0; i < matchs.length; i++) {
_out.print("null");

if (i < matchs.length - 1) {
_out.print(", ");
}
}

_out.println(");");
} else {
int t_pos = bh.getTarget().getPosition();
String target;

if (pos > t_pos) {
target = "ih_" + t_pos;
} else {
branches.add(bi);
target = "null";
}

_out.println(" BranchInstruction " + name + " = _factory.createBranchInstruction(" + "Constants."
+ bi.getName().toUpperCase() + ", " + target + ");");
}

if (bh.hasTargeters()) {
_out.println(" ih_" + pos + " = il.append(" + name + ");");
} else {
_out.println(" il.append(" + name + ");");
}
}

@Override
public void visitRET(RET i) {
_out.println("il.append(new RET(" + i.getIndex() + ")));");
}

private void updateBranchTargets() {
for (Iterator<InstructionBranch> i = branches.iterator(); i.hasNext();) {
InstructionBranch bi = i.next();
BranchHandle bh = (BranchHandle) branch_map.get(bi);
int pos = bh.getPosition();
String name = bi.getName() + "_" + pos;
int t_pos = bh.getTarget().getPosition();

_out.println(" " + name + ".setTarget(ih_" + t_pos + ");");

if (bi instanceof InstructionSelect) {
InstructionHandle[] ihs = ((InstructionSelect) bi).getTargets();

for (int j = 0; j < ihs.length; j++) {
t_pos = ihs[j].getPosition();

_out.println(" " + name + ".setTarget(" + j + ", ih_" + t_pos + ");");
}
}
}
}

private void updateExceptionHandlers() {
CodeExceptionGen[] handlers = _mg.getExceptionHandlers();

for (int i = 0; i < handlers.length; i++) {
CodeExceptionGen h = handlers[i];
String type = h.getCatchType() == null ? "null" : BCELifier.printType(h.getCatchType());

_out.println(" method.addExceptionHandler(" + "ih_" + h.getStartPC().getPosition() + ", " + "ih_"
+ h.getEndPC().getPosition() + ", " + "ih_" + h.getHandlerPC().getPosition() + ", " + type + ");");
}
}
}

+ 0
- 341
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELifier.java View File

@@ -1,341 +0,0 @@
package org.aspectj.apache.bcel.verifier.util;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/
import java.io.OutputStream;
import java.io.PrintWriter;

import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.Repository;
import org.aspectj.apache.bcel.classfile.ClassParser;
import org.aspectj.apache.bcel.classfile.ConstantValue;
import org.aspectj.apache.bcel.classfile.Field;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.Utility;
import org.aspectj.apache.bcel.generic.ArrayType;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.generic.MethodGen;
import org.aspectj.apache.bcel.generic.Type;

/**
* This class takes a given JavaClass object and converts it to a
* Java program that creates that very class using BCEL. This
* gives new users of BCEL a useful example showing how things
* are done with BCEL. It does not cover all features of BCEL,
* but tries to mimic hand-written code as close as possible.
*
* @version $Id: BCELifier.java,v 1.2 2008/05/28 23:53:04 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public class BCELifier extends org.aspectj.apache.bcel.verifier.EmptyClassVisitor {
private JavaClass _clazz;
private PrintWriter _out;
private ConstantPool _cp;

/** @param clazz Java class to "decompile"
* @param out where to output Java program
*/
public BCELifier(JavaClass clazz, OutputStream out) {
_clazz = clazz;
_out = new PrintWriter(out);
_cp = new ConstantPool(_clazz.getConstantPool().getConstantPool());
}

/** Start Java code generation
*/
public void start() {
visitJavaClass(_clazz);
_out.flush();
}

public void visitJavaClass(JavaClass clazz) {
String class_name = clazz.getClassName();
String super_name = clazz.getSuperclassName();
String package_name = clazz.getPackageName();
String inter = BCELifier.printArray(clazz.getInterfaceNames(),
false, true);
if(!"".equals(package_name)) {
class_name = class_name.substring(package_name.length() + 1);
_out.println("package " + package_name + ";\n");
}

_out.println("import org.aspectj.apache.bcel.generic.*;");
_out.println("import org.aspectj.apache.bcel.classfile.*;");
_out.println("import org.aspectj.apache.bcel.*;");
_out.println("import java.io.*;\n");

_out.println("public class " + class_name + "Creator implements Constants {");
_out.println(" private InstructionFactory _factory;");
_out.println(" private ConstantPoolGen _cp;");
_out.println(" private ClassGen _cg;\n");

_out.println(" public " + class_name + "Creator() {");
_out.println(" _cg = new ClassGen(\"" +
(("".equals(package_name))? class_name :
package_name + "." + class_name) +
"\", \"" + super_name + "\", " +
"\"" + clazz.getSourceFileName() + "\", " +
printFlags(clazz.getModifiers(), true) + ", " +
"new String[] { " + inter + " });\n");

_out.println(" _cp = _cg.getConstantPool();");
_out.println(" _factory = new InstructionFactory(_cg, _cp);");
_out.println(" }\n");

printCreate();

Field[] fields = clazz.getFields();

if(fields.length > 0) {
_out.println(" private void createFields() {");
_out.println(" FieldGen field;");

for(int i=0; i < fields.length; i++) {
fields[i].accept(this);
}

_out.println(" }\n");
}

Method[] methods = clazz.getMethods();

for(int i=0; i < methods.length; i++) {
_out.println(" private void createMethod_" + i + "() {");

methods[i].accept(this);
_out.println(" }\n");
}

printMain();
_out.println("}");
}

private void printCreate() {
_out.println(" public void create(OutputStream out) throws IOException {");

Field[] fields = _clazz.getFields();
if(fields.length > 0) {
_out.println(" createFields();");
}

Method[] methods = _clazz.getMethods();
for(int i=0; i < methods.length; i++) {
_out.println(" createMethod_" + i + "();");
}

_out.println(" _cg.getJavaClass().dump(out);");

_out.println(" }\n");
}

private void printMain() {
String class_name = _clazz.getClassName();

_out.println(" public static void main(String[] args) throws Exception {");
_out.println(" " + class_name + "Creator creator = new " +
class_name + "Creator();");
_out.println(" creator.create(new FileOutputStream(\"" + class_name +
".class\"));");
_out.println(" }");
}

public void visitField(Field field) {
_out.println("\n field = new FieldGen(" +
printFlags(field.getModifiers()) +
", " + printType(field.getSignature()) + ", \"" +
field.getName() + "\", _cp);");

ConstantValue cv = field.getConstantValue();

if(cv != null) {
String value = cv.toString();
_out.println(" field.setInitValue(" + value + ")");
}

_out.println(" _cg.addField(field.getField());");
}

public void visitMethod(Method method) {
MethodGen mg = new MethodGen(method, _clazz.getClassName(), _cp);

Type result_type = mg.getReturnType();
Type[] arg_types = mg.getArgumentTypes();

_out.println(" InstructionList il = new InstructionList();");
_out.println(" MethodGen method = new MethodGen(" +
printFlags(method.getModifiers()) +
", " + printType(result_type) +
", " + printArgumentTypes(arg_types) + ", " +
"new String[] { " +
BCELifier.printArray(mg.getArgumentNames(), false, true) +
" }, \"" + method.getName() + "\", \"" +
_clazz.getClassName() + "\", il, _cp);\n");

BCELFactory factory = new BCELFactory(mg, _out);
factory.start();

_out.println(" method.setMaxStack();");
_out.println(" method.setMaxLocals();");
_out.println(" _cg.addMethod(method.getMethod());");
_out.println(" il.dispose();");
}

public static final String printArray(Object[] obj, boolean braces,
boolean quote) {
if(obj == null)
return null;

StringBuffer buf = new StringBuffer();
if(braces)
buf.append('{');

for(int i=0; i < obj.length; i++) {
if(obj[i] != null) {
buf.append((quote? "\"" : "") + obj[i].toString() + (quote? "\"" : ""));
} else {
buf.append("null");
}

if(i < obj.length - 1) {
buf.append(", ");
}
}

if(braces)
buf.append('}');

return buf.toString();
}

static String printFlags(int flags) {
return printFlags(flags, false);
}

static String printFlags(int flags, boolean for_class) {
if(flags == 0)
return "0";

StringBuffer buf = new StringBuffer();
for(int i=0, pow=1; i <= Constants.MAX_ACC_FLAG; i++) {
if((flags & pow) != 0) {
if((pow == Constants.ACC_SYNCHRONIZED) && for_class)
buf.append("ACC_SUPER | ");
else
buf.append("ACC_" + Constants.ACCESS_NAMES[i].toUpperCase() + " | ");
}

pow <<= 1;
}

String str = buf.toString();
return str.substring(0, str.length() - 3);
}

static String printArgumentTypes(Type[] arg_types) {
if(arg_types.length == 0)
return "Type.NO_ARGS";

StringBuffer args = new StringBuffer();

for(int i=0; i < arg_types.length; i++) {
args.append(printType(arg_types[i]));

if(i < arg_types.length - 1)
args.append(", ");
}

return "new Type[] { " + args.toString() + " }";
}

static String printType(Type type) {
return printType(type.getSignature());
}

static String printType(String signature) {
Type type = Type.getType(signature);
byte t = type.getType();

if(t <= Constants.T_VOID) {
return "Type." + Constants.TYPE_NAMES[t].toUpperCase();
} else if(type.toString().equals("java.lang.String")) {
return "Type.STRING";
} else if(type.toString().equals("java.lang.Object")) {
return "Type.OBJECT";
} else if(type.toString().equals("java.lang.StringBuffer")) {
return "Type.STRINGBUFFER";
} else if(type instanceof ArrayType) {
ArrayType at = (ArrayType)type;

return "new ArrayType(" + printType(at.getBasicType()) +
", " + at.getDimensions() + ")";
} else {
return "new ObjectType(\"" + Utility.signatureToString(signature, false) +
"\")";
}
}

/** Default main method
*/
public static void main(String[] argv) throws Exception {
JavaClass java_class;
String name = argv[0];

if((java_class = Repository.lookupClass(name)) == null)
java_class = new ClassParser(name).parse(); // May throw IOException

BCELifier bcelifier = new BCELifier(java_class, System.out);
bcelifier.start();
}
}

+ 0
- 440
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/InstructionFinder.java View File

@@ -1,440 +0,0 @@
package org.aspectj.apache.bcel.verifier.util;

/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (https://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache BCEL" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache BCEL", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <https://www.apache.org/>.
*/

import java.util.*;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.generic.*;
import org.apache.regexp.*;

/**
* InstructionFinder is a tool to search for given instructions patterns,
* i.e., match sequences of instructions in an instruction list via
* regular expressions. This can be used, e.g., in order to implement
* a peep hole optimizer that looks for code patterns and replaces
* them with faster equivalents.
*
* <p>This class internally uses the <a href="https://jakarta.apache.org/regexp/">
* Regexp</a> package to search for regular expressions.
*
* A typical application would look like this:
<pre>
InstructionFinder f = new InstructionFinder(il);
String pat = "IfInstruction ICONST_0 GOTO ICONST_1 NOP (IFEQ|IFNE)";
for(Iterator i = f.search(pat, constraint); i.hasNext(); ) {
InstructionHandle[] match = (InstructionHandle[])i.next();
...
il.delete(match[1], match[5]);
...
}
</pre>
* @version $Id: InstructionFinder.java,v 1.4 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="https://www.berlin.de/~markus.dahm/">M. Dahm</A>
* @see Instruction
* @see InstructionList
*/
public class InstructionFinder {
private static final int OFFSET = 32767; // char + OFFSET is outside of LATIN-1
private static final int NO_OPCODES = 256; // Potential number, some are not used

private static final HashMap<String, String> map = new HashMap<String, String>(); // Map<String,Pattern>

private InstructionList il;
private String il_string; // instruction list as string
private InstructionHandle[] handles; // map instruction list to array

/**
* @param il instruction list to search for given patterns
*/
public InstructionFinder(InstructionList il) {
this.il = il;
reread();
}

/**
* Reread the instruction list, e.g., after you've altered the list upon a match.
*/
public final void reread() {
int size = il.getLength();
char[] buf = new char[size]; // Create a string with length equal to il length
handles = il.getInstructionHandles();

// Map opcodes to characters
for(int i=0; i < size; i++)
buf[i] = makeChar(handles[i].getInstruction().getOpcode());

il_string = new String(buf);
}

/**
* Map symbolic instruction names like "getfield" to a single character.
*
* @param pattern instruction pattern in lower case
* @return encoded string for a pattern such as "BranchInstruction".
*/
private static final String mapName(String pattern) {
String result = map.get(pattern);

if(result != null)
return result;

for(short i=0; i < NO_OPCODES; i++)
if(pattern.equals(Constants.OPCODE_NAMES[i]))
return "" + makeChar(i);

throw new RuntimeException("Instruction unknown: " + pattern);
}

/**
* Replace symbolic names of instructions with the appropiate character and remove
* all white space from string. Meta characters such as +, * are ignored.
*
* @param pattern The pattern to compile
* @return translated regular expression string
*/
private static final String compilePattern(String pattern) {
String lower = pattern.toLowerCase();
StringBuffer buf = new StringBuffer();
int size = pattern.length();

for(int i=0; i < size; i++) {
char ch = lower.charAt(i);
if(Character.isLetterOrDigit(ch)) {
StringBuffer name = new StringBuffer();
while((Character.isLetterOrDigit(ch) || ch == '_') && i < size) {
name.append(ch);

if(++i < size)
ch = lower.charAt(i);
else
break;
}
i--;

buf.append(mapName(name.toString()));
} else if(!Character.isWhitespace(ch))
buf.append(ch);
}

return buf.toString();
}

/**
* @return the matched piece of code as an array of instruction (handles)
*/
private InstructionHandle[] getMatch(int matched_from, int match_length) {
InstructionHandle[] match = new InstructionHandle[match_length];
System.arraycopy(handles, matched_from, match, 0, match_length);

return match;
}

/**
* Search for the given pattern in the instruction list. You can search for any valid
* opcode via its symbolic name, e.g. "istore". You can also use a super class or
* an interface name to match a whole set of instructions, e.g. "BranchInstruction" or
* "LoadInstruction". "istore" is also an alias for all "istore_x" instructions. Additional
* aliases are "if" for "ifxx", "if_icmp" for "if_icmpxx", "if_acmp" for "if_acmpxx".
*
* Consecutive instruction names must be separated by white space which will be removed
* during the compilation of the pattern.
*
* For the rest the usual pattern matching rules for regular expressions apply.<P>
* Example pattern:
* <pre>
search("BranchInstruction NOP ((IfInstruction|GOTO)+ ISTORE Instruction)*");
* </pre>
*
* <p>If you alter the instruction list upon a match such that other
* matching areas are affected, you should call reread() to update
* the finder and call search() again, because the matches are cached.
*
* @param pattern the instruction pattern to search for, where case is ignored
* @param from where to start the search in the instruction list
* @param constraint optional CodeConstraint to check the found code pattern for
* user-defined constraints
* @return iterator of matches where e.nextElement() returns an array of instruction handles
* describing the matched area
*/
public final Iterator<InstructionHandle[]> search(String pattern, InstructionHandle from,
CodeConstraint constraint)
{
String search = compilePattern(pattern);
int start = -1;

for(int i=0; i < handles.length; i++) {
if(handles[i] == from) {
start = i; // Where to start search from (index)
break;
}
}

if(start == -1)
throw new ClassGenException("Instruction handle " + from +
" not found in instruction list.");
try {
RE regex = new RE(search);
ArrayList<InstructionHandle[]> matches = new ArrayList<InstructionHandle[]>();

while(start < il_string.length() && regex.match(il_string, start)) {
int startExpr = regex.getParenStart(0);
int endExpr = regex.getParenEnd(0);
int lenExpr = regex.getParenLength(0);
InstructionHandle[] match = getMatch(startExpr, lenExpr);

if((constraint == null) || constraint.checkCode(match))
matches.add(match);
start = endExpr;
}

return matches.iterator();
} catch(RESyntaxException e) {
System.err.println(e);
}

return null;
}

/**
* Start search beginning from the start of the given instruction list.
*
* @param pattern the instruction pattern to search for, where case is ignored
* @return iterator of matches where e.nextElement()
* returns an array of instruction handles describing the matched
* area
*/
public final Iterator<InstructionHandle[]> search(String pattern) {
return search(pattern, il.getStart(), null);
}

/**
* Start search beginning from `from'.
*
* @param pattern the instruction pattern to search for, where case is ignored
* @param from where to start the search in the instruction list
* @return iterator of matches where e.nextElement() returns an array of instruction handles
* describing the matched area
*/
public final Iterator<InstructionHandle[]> search(String pattern, InstructionHandle from) {
return search(pattern, from, null);
}

/**
* Start search beginning from the start of the given instruction list.
* Check found matches with the constraint object.
*
* @param pattern the instruction pattern to search for, case is ignored
* @param constraint constraints to be checked on matching code
* @return instruction handle or `null' if the match failed
*/
public final Iterator<InstructionHandle[]> search(String pattern, CodeConstraint constraint) {
return search(pattern, il.getStart(), constraint);
}

/**
* Convert opcode number to char.
*/
private static final char makeChar(short opcode) {
return (char)(opcode + OFFSET);
}

/**
* @return the inquired instruction list
*/
public final InstructionList getInstructionList() { return il; }

/**
* Code patterns found may be checked using an additional
* user-defined constraint object whether they really match the needed criterion.
* I.e., check constraints that can not expressed with regular expressions.
*
*/
public interface CodeConstraint {
/**
* @param match array of instructions matching the requested pattern
* @return true if the matched area is really useful
*/
public boolean checkCode(InstructionHandle[] match);
}

// Initialize pattern map

static {
map.put("arithmeticinstruction", "(irem|lrem|iand|ior|ineg|isub|lneg|fneg|fmul|ldiv|fadd|lxor|frem|idiv|land|ixor|ishr|fsub|lshl|fdiv|iadd|lor|dmul|lsub|ishl|imul|lmul|lushr|dneg|iushr|lshr|ddiv|drem|dadd|ladd|dsub)");
map.put("invokeinstruction", "(invokevirtual|invokeinterface|invokestatic|invokespecial)");
map.put("arrayinstruction", "(baload|aastore|saload|caload|fastore|lastore|iaload|castore|iastore|aaload|bastore|sastore|faload|laload|daload|dastore)");
map.put("gotoinstruction", "(goto|goto_w)");
map.put("conversioninstruction", "(d2l|l2d|i2s|d2i|l2i|i2b|l2f|d2f|f2i|i2d|i2l|f2d|i2c|f2l|i2f)");
map.put("localvariableinstruction", "(fstore|iinc|lload|dstore|dload|iload|aload|astore|istore|fload|lstore)");
map.put("loadinstruction", "(fload|dload|lload|iload|aload)");
map.put("fieldinstruction", "(getfield|putstatic|getstatic|putfield)");
map.put("cpinstruction", "(ldc2_w|invokeinterface|multianewarray|putstatic|instanceof|getstatic|checkcast|getfield|invokespecial|ldc_w|invokestatic|invokevirtual|putfield|ldc|new|anewarray)");
map.put("stackinstruction", "(dup2|swap|dup2_x2|pop|pop2|dup|dup2_x1|dup_x2|dup_x1)");
map.put("branchinstruction", "(ifle|if_acmpne|if_icmpeq|if_acmpeq|ifnonnull|goto_w|iflt|ifnull|if_icmpne|tableswitch|if_icmple|ifeq|if_icmplt|jsr_w|if_icmpgt|ifgt|jsr|goto|ifne|ifge|lookupswitch|if_icmpge)");
map.put("returninstruction", "(lreturn|ireturn|freturn|dreturn|areturn|return)");
map.put("storeinstruction", "(istore|fstore|dstore|astore|lstore)");
map.put("select", "(tableswitch|lookupswitch)");
map.put("ifinstruction", "(ifeq|ifgt|if_icmpne|if_icmpeq|ifge|ifnull|ifne|if_icmple|if_icmpge|if_acmpeq|if_icmplt|if_acmpne|ifnonnull|iflt|if_icmpgt|ifle)");
map.put("jsrinstruction", "(jsr|jsr_w)");
map.put("variablelengthinstruction", "(tableswitch|jsr|goto|lookupswitch)");
map.put("unconditionalbranch", "(goto|jsr|jsr_w|athrow|goto_w)");
map.put("constantpushinstruction", "(dconst|bipush|sipush|fconst|iconst|lconst)");
map.put("typedinstruction", "(imul|lsub|aload|fload|lor|new|aaload|fcmpg|iand|iaload|lrem|idiv|d2l|isub|dcmpg|dastore|ret|f2d|f2i|drem|iinc|i2c|checkcast|frem|lreturn|astore|lushr|daload|dneg|fastore|istore|lshl|ldiv|lstore|areturn|ishr|ldc_w|invokeinterface|aastore|lxor|ishl|l2d|i2f|return|faload|sipush|iushr|caload|instanceof|invokespecial|putfield|fmul|ireturn|laload|d2f|lneg|ixor|i2l|fdiv|lastore|multianewarray|i2b|getstatic|i2d|putstatic|fcmpl|saload|ladd|irem|dload|jsr_w|dconst|dcmpl|fsub|freturn|ldc|aconst_null|castore|lmul|ldc2_w|dadd|iconst|f2l|ddiv|dstore|land|jsr|anewarray|dmul|bipush|dsub|sastore|d2i|i2s|lshr|iadd|l2i|lload|bastore|fstore|fneg|iload|fadd|baload|fconst|ior|ineg|dreturn|l2f|lconst|getfield|invokevirtual|invokestatic|iastore)");
map.put("popinstruction", "(fstore|dstore|pop|pop2|astore|putstatic|istore|lstore)");
map.put("allocationinstruction", "(multianewarray|new|anewarray|newarray)");
map.put("indexedinstruction", "(lload|lstore|fload|ldc2_w|invokeinterface|multianewarray|astore|dload|putstatic|instanceof|getstatic|checkcast|getfield|invokespecial|dstore|istore|iinc|ldc_w|ret|fstore|invokestatic|iload|putfield|invokevirtual|ldc|new|aload|anewarray)");
map.put("pushinstruction", "(dup|lload|dup2|bipush|fload|ldc2_w|sipush|lconst|fconst|dload|getstatic|ldc_w|aconst_null|dconst|iload|ldc|iconst|aload)");
map.put("stackproducer", "(imul|lsub|aload|fload|lor|new|aaload|fcmpg|iand|iaload|lrem|idiv|d2l|isub|dcmpg|dup|f2d|f2i|drem|i2c|checkcast|frem|lushr|daload|dneg|lshl|ldiv|ishr|ldc_w|invokeinterface|lxor|ishl|l2d|i2f|faload|sipush|iushr|caload|instanceof|invokespecial|fmul|laload|d2f|lneg|ixor|i2l|fdiv|getstatic|i2b|swap|i2d|dup2|fcmpl|saload|ladd|irem|dload|jsr_w|dconst|dcmpl|fsub|ldc|arraylength|aconst_null|tableswitch|lmul|ldc2_w|iconst|dadd|f2l|ddiv|land|jsr|anewarray|dmul|bipush|dsub|d2i|newarray|i2s|lshr|iadd|lload|l2i|fneg|iload|fadd|baload|fconst|lookupswitch|ior|ineg|lconst|l2f|getfield|invokevirtual|invokestatic)");
map.put("stackconsumer", "(imul|lsub|lor|iflt|fcmpg|if_icmpgt|iand|ifeq|if_icmplt|lrem|ifnonnull|idiv|d2l|isub|dcmpg|dastore|if_icmpeq|f2d|f2i|drem|i2c|checkcast|frem|lreturn|astore|lushr|pop2|monitorexit|dneg|fastore|istore|lshl|ldiv|lstore|areturn|if_icmpge|ishr|monitorenter|invokeinterface|aastore|lxor|ishl|l2d|i2f|return|iushr|instanceof|invokespecial|fmul|ireturn|d2f|lneg|ixor|pop|i2l|ifnull|fdiv|lastore|i2b|if_acmpeq|ifge|swap|i2d|putstatic|fcmpl|ladd|irem|dcmpl|fsub|freturn|ifgt|castore|lmul|dadd|f2l|ddiv|dstore|land|if_icmpne|if_acmpne|dmul|dsub|sastore|ifle|d2i|i2s|lshr|iadd|l2i|bastore|fstore|fneg|fadd|ior|ineg|ifne|dreturn|l2f|if_icmple|getfield|invokevirtual|invokestatic|iastore)");
map.put("exceptionthrower", "(irem|lrem|laload|putstatic|baload|dastore|areturn|getstatic|ldiv|anewarray|iastore|castore|idiv|saload|lastore|fastore|putfield|lreturn|caload|getfield|return|aastore|freturn|newarray|instanceof|multianewarray|athrow|faload|iaload|aaload|dreturn|monitorenter|checkcast|bastore|arraylength|new|invokevirtual|sastore|ldc_w|ireturn|invokespecial|monitorexit|invokeinterface|ldc|invokestatic|daload)");
map.put("loadclass", "(multianewarray|invokeinterface|instanceof|invokespecial|putfield|checkcast|putstatic|invokevirtual|new|getstatic|invokestatic|getfield|anewarray)");
map.put("instructiontargeter", "(ifle|if_acmpne|if_icmpeq|if_acmpeq|ifnonnull|goto_w|iflt|ifnull|if_icmpne|tableswitch|if_icmple|ifeq|if_icmplt|jsr_w|if_icmpgt|ifgt|jsr|goto|ifne|ifge|lookupswitch|if_icmpge)");

// Some aliases
map.put("if_icmp", "(if_icmpne|if_icmpeq|if_icmple|if_icmpge|if_icmplt|if_icmpgt)");
map.put("if_acmp", "(if_acmpeq|if_acmpne)");
map.put("if", "(ifeq|ifne|iflt|ifge|ifgt|ifle)");

// Precompile some aliases first
map.put("iconst", precompile(Constants.ICONST_0, Constants.ICONST_5, Constants.ICONST_M1));
map.put("lconst", new String(new char[] { '(', makeChar(Constants.LCONST_0), '|',
makeChar(Constants.LCONST_1), ')' }));
map.put("dconst", new String(new char[] { '(', makeChar(Constants.DCONST_0), '|',
makeChar(Constants.DCONST_1), ')' }));
map.put("fconst", new String(new char[] { '(', makeChar(Constants.FCONST_0), '|',
makeChar(Constants.FCONST_1), ')' }));

map.put("iload", precompile(Constants.ILOAD_0, Constants.ILOAD_3, Constants.ILOAD));
map.put("dload", precompile(Constants.DLOAD_0, Constants.DLOAD_3, Constants.DLOAD));
map.put("fload", precompile(Constants.FLOAD_0, Constants.FLOAD_3, Constants.FLOAD));
map.put("aload", precompile(Constants.ALOAD_0, Constants.ALOAD_3, Constants.ALOAD));

map.put("istore", precompile(Constants.ISTORE_0, Constants.ISTORE_3, Constants.ISTORE));
map.put("dstore", precompile(Constants.DSTORE_0, Constants.DSTORE_3, Constants.DSTORE));
map.put("fstore", precompile(Constants.FSTORE_0, Constants.FSTORE_3, Constants.FSTORE));
map.put("astore", precompile(Constants.ASTORE_0, Constants.ASTORE_3, Constants.ASTORE));

// Compile strings

for(Iterator<String> i = map.keySet().iterator(); i.hasNext(); ) {
String key = i.next();
String value = map.get(key);

char ch = value.charAt(1); // Omit already precompiled patterns
if(ch < OFFSET) {
map.put(key, compilePattern(value)); // precompile all patterns
}
}

// Add instruction alias to match anything

StringBuffer buf = new StringBuffer("(");
for(short i=0; i < NO_OPCODES; i++) {
if(Constants.iLen[i] != Constants.UNDEFINED_LENGTH) { // Not an invalid opcode
buf.append(makeChar(i));

if(i < NO_OPCODES - 1)
buf.append('|');
}
}
buf.append(')');

map.put("instruction", buf.toString());
}

private static String precompile(short from, short to, short extra) {
StringBuffer buf = new StringBuffer("(");

for(short i=from; i <= to; i++) {
buf.append(makeChar(i));
buf.append('|');
}

buf.append(makeChar(extra));
buf.append(")");
return buf.toString();
}

// /*
// * Internal debugging routines.
// */
// private static final String pattern2string(String pattern) {
// return pattern2string(pattern, true);
// }
//
// private static final String pattern2string(String pattern, boolean make_string) {
// StringBuffer buf = new StringBuffer();
//
// for(int i=0; i < pattern.length(); i++) {
// char ch = pattern.charAt(i);
//
// if(ch >= OFFSET) {
// if(make_string)
// buf.append(Constants.OPCODE_NAMES[ch - OFFSET]);
// else
// buf.append((int)(ch - OFFSET));
// } else
// buf.append(ch);
// }
//
// return buf.toString();
// }
}

Loading…
Cancel
Save