2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package gov.nasa.jpf.jvm;
21 import gov.nasa.jpf.vm.ClassParseException;
24 * interface for classfile processors
26 * NOTE - all types are given ss descriptors, i.e. "Lx/y/Z;" or type codes such as "I"
28 * iteration groups always start with a
29 * setXCount(int xCount)
31 * followed by xCount notifications
34 * with 0<=xIndex<xCount
36 public interface ClassFileReader {
38 void setClass(ClassFile cf, String clsName, String superClsName, int flags, int cpCount) throws ClassParseException;
42 void setInterfaceCount(ClassFile cf, int ifcCount);
44 void setInterface(ClassFile cf, int ifcIndex, String ifcName);
46 void setInterfacesDone(ClassFile cf);
50 void setFieldCount(ClassFile cf, int fieldCount);
52 void setField(ClassFile cf, int fieldIndex, int accessFlags, String name, String descriptor);
54 void setFieldAttributeCount(ClassFile cf, int fieldIndex, int attrCount);
56 void setFieldAttribute(ClassFile cf, int fieldIndex, int attrIndex, String name, int attrLength);
58 void setFieldAttributesDone(ClassFile cf, int fieldIndex);
60 void setFieldDone(ClassFile cf, int fieldIndex);
62 void setFieldsDone(ClassFile cf);
65 //--- standard field attributes
66 void setConstantValue(ClassFile cf, Object tag, Object value);
70 void setMethodCount(ClassFile cf, int methodCount);
72 void setMethod(ClassFile cf, int methodIndex, int accessFlags, String name, String descriptor);
74 void setMethodAttributeCount(ClassFile cf, int methodIndex, int attrCount);
76 void setMethodAttribute(ClassFile cf, int methodIndex, int attrIndex, String name, int attrLength);
78 void setMethodAttributesDone(ClassFile cf, int methodIndex);
80 void setMethodDone(ClassFile cf, int methodIndex);
82 void setMethodsDone(ClassFile cf);
85 //--- standard method attributes
86 void setExceptionCount (ClassFile cf, Object tag, int exceptionCount);
88 void setException (ClassFile cf, Object tag, int exceptionIndex, String exceptionType);
90 void setExceptionsDone(ClassFile cf, Object tag);
92 void setCode(ClassFile cf, Object tag, int maxStack, int maxLocals, int codeLength);
94 void setExceptionHandlerTableCount (ClassFile cf, Object tag, int exceptionTableCount);
96 void setExceptionHandler(ClassFile cf, Object tag, int exceptionIndex, int startPc, int endPc, int handlerPc, String catchType);
98 void setExceptionHandlerTableDone(ClassFile cf, Object tag);
100 void setCodeAttributeCount(ClassFile cf, Object tag, int attrCount);
102 void setCodeAttribute(ClassFile cf, Object tag, int attrIndex, String name, int attrLength);
104 void setCodeAttributesDone (ClassFile cf, Object tag);
107 //--- standard code attribute attributes (yes, attributes can be nested)
108 void setLineNumberTableCount(ClassFile cf, Object tag, int lineNumberCount);
110 void setLineNumber(ClassFile cf, Object tag, int lineIndex, int lineNumber, int startPc);
112 void setLineNumberTableDone(ClassFile cf, Object tag);
115 void setLocalVarTableCount(ClassFile cf, Object tag, int localVarCount);
117 void setLocalVar(ClassFile cf, Object tag, int localVarIndex, String varName, String descriptor,
118 int scopeStartPc, int scopeEndPc, int slotIndex);
120 void setLocalVarTableDone(ClassFile cf, Object tag);
123 void setClassAttributeCount(ClassFile cf, int attrCount);
125 void setClassAttribute(ClassFile cf, int attrIndex, String name, int attrLength);
127 void setClassAttributesDone(ClassFile cf);
130 //--- standard class attributes
131 void setSourceFile(ClassFile cf, Object tag, String pathName);
133 void setInnerClassCount(ClassFile cf, Object tag, int innerClsCount);
134 void setInnerClass(ClassFile cf, Object tag, int innerClsIndex, String outerName, String innerName, String innerSimpleName, int accessFlags);
135 void setInnerClassesDone (ClassFile cf, Object tag);
137 void setBootstrapMethodCount (ClassFile cf, Object tag, int count);
138 void setBootstrapMethod (ClassFile cf, Object tag, int idx, int refKind, String cls, String mth, String descriptor, int[] cpArgs);
139 void setBootstrapMethodsDone (ClassFile cf, Object tag);
141 void setEnclosingMethod(ClassFile cf, Object tag, String enclosingClass, String enclosingMethod, String descriptor);
144 void setAnnotationCount(ClassFile cf, Object tag, int annotationCount);
145 void setAnnotation(ClassFile cf, Object tag, int annotationIndex, String annotationType);
146 void setAnnotationsDone(ClassFile cf, Object tag);
149 // Java 8 type annotations
150 void setTypeAnnotationCount(ClassFile cf, Object tag, int annotationCount);
152 void setTypeParameterAnnotation(ClassFile cf, Object tag, int annotationIndex, int targetType, int typeIndex, short[] typePath, String annotationType);
153 void setSuperTypeAnnotation(ClassFile cf, Object tag, int annotationIndex, int targetType, int superTypeIdx, short[] typePath, String annotationType);
154 void setTypeParameterBoundAnnotation(ClassFile cf, Object tag, int annotationIndex, int targetType, int typeParamIdx, int boundIdx, short[] typePath, String annotationType);
155 void setTypeAnnotation(ClassFile cf, Object tag, int annotationIndex, int targetType, short[] typePath, String annotationType);
156 void setFormalParameterAnnotation(ClassFile cf, Object tag, int annotationIndex, int targetType, int formalParamIndex, short[] typePath, String annotationType);
157 void setThrowsAnnotation(ClassFile cf, Object tag, int annotationIndex, int targetType, int throwsTypeIndex, short[] typePath, String annotationType);
158 void setVariableAnnotation(ClassFile cf, Object tag, int annotationIndex, int targetType, long[] scopeEntries, short[] typePath, String annotationType);
159 void setExceptionParameterAnnotation(ClassFile cf, Object tag, int annotationIndex, int targetType, int exceptionIndex, short[] typePath, String annotationType);
160 void setBytecodeAnnotation(ClassFile cf, Object tag, int annotationIndex, int targetType, int offset, short[] typePath, String annotationType);
161 void setBytecodeTypeParameterAnnotation(ClassFile cf, Object tag, int annotationIndex, int targetType, int offset, int typeArgIdx, short[] typePath, String annotationType);
163 void setTypeAnnotationsDone(ClassFile cf, Object tag);
167 void setAnnotationValueCount(ClassFile cf, Object tag, int annotationIndex, int nValuePairs);
169 void setPrimitiveAnnotationValue(ClassFile cf, Object tag, int annotationIndex, int valueIndex, String elementName, int arrayIndex, Object val);
171 void setStringAnnotationValue(ClassFile cf, Object tag, int annotationIndex, int valueIndex, String elementName, int arrayIndex, String s);
173 void setClassAnnotationValue(ClassFile cf, Object tag, int annotationIndex, int valueIndex, String elementName, int arrayIndex, String typeName);
175 void setEnumAnnotationValue(ClassFile cf, Object tag, int annotationIndex, int valueIndex, String elementName, int arrayIndex,
176 String enumType, String enumValue);
178 void setAnnotationValueElementCount(ClassFile cf, Object tag, int annotationIndex, int valueIndex, String elementName, int elementCount);
180 void setAnnotationValueElementsDone(ClassFile cf, Object tag, int annotationIndex, int valueIndex, String elementName);
182 void setAnnotationValuesDone(ClassFile cf, Object tag, int annotationIndex);
184 void setParameterCount(ClassFile cf, Object tag, int parameterCount);
186 void setParameterAnnotationCount(ClassFile cf, Object tag, int paramIndex, int annotationCount);
188 void setParameterAnnotation(ClassFile cf, Object tag, int annotationIndex, String annotationType);
190 void setParameterAnnotationsDone(ClassFile cf, Object tag, int paramIndex);
192 void setParametersDone(ClassFile cf, Object tag);
195 void setSignature(ClassFile cf, Object tag, String signature);