~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/ikvm/runtime/JavaException.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Jeroen Frijters
 
3
 
 
4
  This software is provided 'as-is', without any express or implied
 
5
  warranty.  In no event will the authors be held liable for any damages
 
6
  arising from the use of this software.
 
7
 
 
8
  Permission is granted to anyone to use this software for any purpose,
 
9
  including commercial applications, and to alter it and redistribute it
 
10
  freely, subject to the following restrictions:
 
11
 
 
12
  1. The origin of this software must not be misrepresented; you must not
 
13
     claim that you wrote the original software. If you use this software
 
14
     in a product, an acknowledgment in the product documentation would be
 
15
     appreciated but is not required.
 
16
  2. Altered source versions must be plainly marked as such, and must not be
 
17
     misrepresented as being the original software.
 
18
  3. This notice may not be removed or altered from any source distribution.
 
19
 
 
20
  Jeroen Frijters
 
21
  jeroen@frijters.net
 
22
  
 
23
*/
 
24
using System;
 
25
using System.Reflection;
 
26
using IKVM.Internal;
 
27
 
 
28
abstract class RetargetableJavaException : ApplicationException
 
29
{
 
30
        internal RetargetableJavaException(string msg) : base(msg)
 
31
        {
 
32
        }
 
33
 
 
34
        internal RetargetableJavaException(string msg, Exception x) : base(msg, x)
 
35
        {
 
36
        }
 
37
 
 
38
        internal static string Format(string s, object[] args)
 
39
        {
 
40
                if (args == null || args.Length == 0)
 
41
                {
 
42
                        return s;
 
43
                }
 
44
                return String.Format(s, args);
 
45
        }
 
46
 
 
47
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
 
48
        internal abstract Exception ToJava();
 
49
#elif FIRST_PASS
 
50
        internal virtual Exception ToJava()
 
51
        {
 
52
                return null;
 
53
        }
 
54
#endif
 
55
}
 
56
 
 
57
// NOTE this is not a Java exception, but instead it wraps a Java exception that
 
58
// was thrown by a class loader. It is used so ClassFile.LoadClassHelper() can catch
 
59
// Java exceptions and turn them into UnloadableTypeWrappers without inadvertantly
 
60
// hiding exceptions caused by coding errors in the IKVM code.
 
61
sealed class ClassLoadingException : RetargetableJavaException
 
62
{
 
63
        internal ClassLoadingException(Exception x)
 
64
                : base(x.Message, x)
 
65
        {
 
66
        }
 
67
 
 
68
#if !STATIC_COMPILER && !STUB_GENERATOR
 
69
        internal override Exception ToJava()
 
70
        {
 
71
                return InnerException;
 
72
        }
 
73
#endif
 
74
}
 
75
 
 
76
class LinkageError : RetargetableJavaException
 
77
{
 
78
        internal LinkageError(string msg) : base(msg)
 
79
        {
 
80
        }
 
81
 
 
82
        internal LinkageError(string msg, Exception x) : base(msg, x)
 
83
        {
 
84
        }
 
85
 
 
86
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
 
87
        internal override Exception ToJava()
 
88
        {
 
89
                return new java.lang.LinkageError(Message);
 
90
        }
 
91
#endif
 
92
}
 
93
 
 
94
sealed class VerifyError : LinkageError
 
95
{
 
96
        internal VerifyError() : base("")
 
97
        {
 
98
        }
 
99
 
 
100
        internal VerifyError(string msg) : base(msg)
 
101
        {
 
102
        }
 
103
 
 
104
        internal VerifyError(string msg, Exception x) : base(msg, x)
 
105
        {
 
106
        }
 
107
 
 
108
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
 
109
        internal override Exception ToJava()
 
110
        {
 
111
                return new java.lang.VerifyError(Message);
 
112
        }
 
113
#endif
 
114
}
 
115
 
 
116
sealed class ClassNotFoundException : RetargetableJavaException
 
117
{
 
118
        internal ClassNotFoundException(string name) : base(name)
 
119
        {
 
120
        }
 
121
 
 
122
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
 
123
        internal override Exception ToJava()
 
124
        {
 
125
                return new java.lang.ClassNotFoundException(Message);
 
126
        }
 
127
#endif
 
128
}
 
129
 
 
130
sealed class ClassCircularityError : LinkageError
 
131
{
 
132
        internal ClassCircularityError(string msg) : base(msg)
 
133
        {
 
134
        }
 
135
 
 
136
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
 
137
        internal override Exception ToJava()
 
138
        {
 
139
                return new java.lang.ClassCircularityError(Message);
 
140
        }
 
141
#endif
 
142
}
 
143
 
 
144
sealed class NoClassDefFoundError : LinkageError
 
145
{
 
146
        internal NoClassDefFoundError(string msg) : base(msg)
 
147
        {
 
148
        }
 
149
 
 
150
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
 
151
        internal override Exception ToJava()
 
152
        {
 
153
                return new java.lang.NoClassDefFoundError(Message);
 
154
        }
 
155
#endif
 
156
}
 
157
 
 
158
class IncompatibleClassChangeError : LinkageError
 
159
{
 
160
        internal IncompatibleClassChangeError(string msg) : base(msg)
 
161
        {
 
162
        }
 
163
 
 
164
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
 
165
        internal override Exception ToJava()
 
166
        {
 
167
                return new java.lang.IncompatibleClassChangeError(Message);
 
168
        }
 
169
#endif
 
170
}
 
171
 
 
172
sealed class IllegalAccessError : IncompatibleClassChangeError
 
173
{
 
174
        internal IllegalAccessError(string msg) : base(msg)
 
175
        {
 
176
        }
 
177
 
 
178
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
 
179
        internal override Exception ToJava()
 
180
        {
 
181
                return new java.lang.IllegalAccessError(Message);
 
182
        }
 
183
#endif
 
184
}
 
185
 
 
186
class ClassFormatError : LinkageError
 
187
{
 
188
        internal ClassFormatError(string msg, params object[] p)
 
189
                : base(Format(msg, p))
 
190
        {
 
191
        }
 
192
 
 
193
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
 
194
        internal override Exception ToJava()
 
195
        {
 
196
                return new java.lang.ClassFormatError(Message);
 
197
        }
 
198
#endif
 
199
}
 
200
 
 
201
sealed class UnsupportedClassVersionError : ClassFormatError
 
202
{
 
203
        internal UnsupportedClassVersionError(string msg)
 
204
                : base(msg)
 
205
        {
 
206
        }
 
207
 
 
208
#if !STATIC_COMPILER && !FIRST_PASS && !STUB_GENERATOR
 
209
        internal override Exception ToJava()
 
210
        {
 
211
                return new java.lang.UnsupportedClassVersionError(Message);
 
212
        }
 
213
#endif
 
214
}