1 11 package org.eclipse.jdt.internal.compiler.classfmt; 12 import java.io.PrintStream ; 13 import java.io.PrintWriter ; 14 public class ClassFormatException extends Exception { 15 16 public static final int ErrBadMagic = 1; 17 public static final int ErrBadMinorVersion = 2; 18 public static final int ErrBadMajorVersion = 3; 19 public static final int ErrBadConstantClass = 4; 20 public static final int ErrBadConstantString = 5; 21 public static final int ErrBadConstantNameAndType = 6; 22 public static final int ErrBadConstantFieldRef = 7; 23 public static final int ErrBadConstantMethodRef = 8; 24 public static final int ErrBadConstantInterfaceMethodRef = 9; 25 public static final int ErrBadConstantPoolIndex = 10; 26 public static final int ErrBadSuperclassName = 11; 27 public static final int ErrInterfaceCannotBeFinal = 12; 28 public static final int ErrInterfaceMustBeAbstract = 13; 29 public static final int ErrBadModifiers = 14; 30 public static final int ErrClassCannotBeAbstractFinal = 15; 31 public static final int ErrBadClassname = 16; 32 public static final int ErrBadFieldInfo = 17; 33 public static final int ErrBadMethodInfo = 17; 34 public static final int ErrEmptyConstantPool = 18; 35 public static final int ErrMalformedUtf8 = 19; 36 public static final int ErrUnknownConstantTag = 20; 37 public static final int ErrTruncatedInput = 21; 38 public static final int ErrMethodMustBeAbstract = 22; 39 public static final int ErrMalformedAttribute = 23; 40 public static final int ErrBadInterface = 24; 41 public static final int ErrInterfaceMustSubclassObject = 25; 42 public static final int ErrIncorrectInterfaceMethods = 26; 43 public static final int ErrInvalidMethodName = 27; 44 public static final int ErrInvalidMethodSignature = 28; 45 46 private static final long serialVersionUID = 6667458511042774540L; 48 private int errorCode; 49 private int bufferPosition; 50 private RuntimeException nestedException; 51 private char[] fileName; 52 53 public ClassFormatException(RuntimeException e, char[] fileName) { 54 this.nestedException = e; 55 this.fileName = fileName; 56 } 57 public ClassFormatException(int code) { 58 errorCode = code; 59 } 60 public ClassFormatException(int code, int bufPos) { 61 errorCode = code; 62 bufferPosition = bufPos; 63 } 64 67 public int getErrorCode() { 68 return errorCode; 69 } 70 73 public int getBufferPosition() { 74 return bufferPosition; 75 } 76 82 public Throwable getException() { 83 return this.nestedException; 84 } 85 public void printStackTrace() { 86 printStackTrace(System.err); 87 } 88 95 public void printStackTrace(PrintStream output) { 96 synchronized (output) { 97 super.printStackTrace(output); 98 Throwable throwable = getException(); 99 if (throwable != null) { 100 if (this.fileName != null) { 101 output.print("Caused in "); output.print(this.fileName); 103 output.print(" by: "); } else { 105 output.print("Caused by: "); } 107 throwable.printStackTrace(output); 108 } 109 } 110 } 111 118 public void printStackTrace(PrintWriter output) { 119 synchronized (output) { 120 super.printStackTrace(output); 121 Throwable throwable = getException(); 122 if (throwable != null) { 123 if (this.fileName != null) { 124 output.print("Caused in "); output.print(this.fileName); 126 output.print(" by: "); } else { 128 output.print("Caused by: "); } 130 throwable.printStackTrace(output); 131 } 132 } 133 } 134 } 135 | Popular Tags |