KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > julia > asm > ClassGenerationException


1 /***
2  * Julia: France Telecom's implementation of the Fractal API
3  * Copyright (C) 2001-2002 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: Eric.Bruneton@rd.francetelecom.com
20  *
21  * Author: Eric Bruneton
22  */

23
24 package org.objectweb.fractal.julia.asm;
25
26 import java.io.PrintStream JavaDoc;
27 import java.io.PrintWriter JavaDoc;
28
29 /**
30  * Thrown when a problem occurs during the generation of a class. See {@link
31  * ClassGenerator#generateClass generateClass}.
32  */

33
34 public class ClassGenerationException extends ClassNotFoundException JavaDoc {
35
36   /**
37    * The exception that caused this exception. May be <tt>null</tt>.
38    */

39
40   private Throwable JavaDoc exception;
41
42   /**
43    * The class descriptor of the class that cannot be generated.
44    */

45
46   private String JavaDoc classDescriptor;
47
48   /**
49    * Constructs a new {@link ClassGenerationException} object.
50    *
51    * @param exception the cause of this exception. May be <tt>null</tt>.
52    * @param classDescriptor the class descriptor of the class that cannot be
53    * generated.
54    * @param message the name of the interface that cannot be found.
55    */

56
57   public ClassGenerationException (
58     final Throwable JavaDoc exception,
59     final String JavaDoc classDescriptor,
60     final String JavaDoc message)
61   {
62     super("Cannot generate the " + classDescriptor + " class. " + message);
63     this.exception = exception;
64     this.classDescriptor = classDescriptor;
65   }
66
67   public Throwable JavaDoc getException () {
68     return exception;
69   }
70
71   /**
72    * Returns the class descriptor of the class that cannot be generated.
73    *
74    * @return the class descriptor of the class that cannot be generated.
75    */

76
77   public String JavaDoc getClassDescriptor () {
78     return classDescriptor;
79   }
80
81   /**
82    * Prints the stack backtrace.
83    */

84
85   public void printStackTrace () {
86     if (exception != null) {
87       System.err.println(this);
88       exception.printStackTrace();
89     } else {
90       super.printStackTrace();
91     }
92   }
93
94   /**
95    * Prints this exception and its backtrace to the specified print stream.
96    *
97    * @param s <tt>PrintStream</tt> to use for output.
98    */

99
100   public void printStackTrace (final PrintStream JavaDoc s) {
101     if (exception != null) {
102       s.println(this);
103       exception.printStackTrace(s);
104     } else {
105       super.printStackTrace(s);
106     }
107   }
108
109   /**
110    * Prints this exception and its backtrace to the specified print writer.
111    *
112    * @param s <tt>PrintWriter</tt> to use for output.
113    */

114
115   public void printStackTrace (final PrintWriter JavaDoc s) {
116     if (exception != null) {
117       s.write(this + "\n");
118       exception.printStackTrace(s);
119     } else {
120       super.printStackTrace(s);
121     }
122   }
123 }
124
Popular Tags