Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
f9edddab
Commit
f9edddab
authored
Feb 23, 2001
by
Per Bothner
Committed by
Per Bothner
Feb 23, 2001
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change to sometimes include class name in ClassFormatError message.
From-SVN: r40030
parent
5ea1bc0e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
115 additions
and
55 deletions
+115
-55
libjava/ChangeLog
+14
-0
libjava/defineclass.cc
+93
-49
libjava/include/java-interp.h
+5
-5
libjava/java/lang/natClassLoader.cc
+3
-1
No files found.
libjava/ChangeLog
View file @
f9edddab
2001-02-23 Per Bothner <per@bothner.com>
2001-02-23 Per Bothner <per@bothner.com>
Change to sometimes include class name in ClassFormatError message.
* defineclass.cc (_Jv_VerifyFieldSignature, _Jv_VerifyMethodSignature,
_Jv_VerifyIdentifier, _Jv_VerifyClassName (two overlods)): Return
boolean instead of throwing ClassFormatError on failure.
(throw_class_format_error): Change static function to method.
(_Jv_ClassReader): New inline methods verify_identifier,
two overloads of verify_classname, verify_field_signature, and
verify_method_signature
* include/java-interp.h: Update declarations to return bool.
* java/lang/natClassLoader.cc (defineClass0): Explicitly throw
ClassFormatError since _Jv_VerifyClassName now returns bool.
2001-02-23 Per Bothner <per@bothner.com>
* java/lang/Throwable.java (CPlusPlusDemangler): Pass -s java to
* java/lang/Throwable.java (CPlusPlusDemangler): Pass -s java to
c++filt to select java-style output.
c++filt to select java-style output.
...
...
libjava/defineclass.cc
View file @
f9edddab
...
@@ -56,8 +56,6 @@ static void throw_no_class_def_found_error (char *msg)
...
@@ -56,8 +56,6 @@ static void throw_no_class_def_found_error (char *msg)
__attribute__
((
__noreturn__
));
__attribute__
((
__noreturn__
));
static
void
throw_class_format_error
(
jstring
msg
)
static
void
throw_class_format_error
(
jstring
msg
)
__attribute__
((
__noreturn__
));
__attribute__
((
__noreturn__
));
static
void
throw_class_format_error
(
char
*
msg
)
__attribute__
((
__noreturn__
));
static
void
throw_incompatible_class_change_error
(
jstring
msg
)
static
void
throw_incompatible_class_change_error
(
jstring
msg
)
__attribute__
((
__noreturn__
));
__attribute__
((
__noreturn__
));
static
void
throw_class_circularity_error
(
jstring
msg
)
static
void
throw_class_circularity_error
(
jstring
msg
)
...
@@ -191,6 +189,36 @@ struct _Jv_ClassReader {
...
@@ -191,6 +189,36 @@ struct _Jv_ClassReader {
throw_class_format_error
(
"erroneous constant pool tag"
);
throw_class_format_error
(
"erroneous constant pool tag"
);
}
}
inline
void
verify_identifier
(
_Jv_Utf8Const
*
name
)
{
if
(
!
_Jv_VerifyIdentifier
(
name
))
throw_class_format_error
(
"erroneous identifier"
);
}
inline
void
verify_classname
(
unsigned
char
*
ptr
,
_Jv_ushort
length
)
{
if
(
!
_Jv_VerifyClassName
(
ptr
,
length
))
throw_class_format_error
(
"erroneous class name"
);
}
inline
void
verify_classname
(
_Jv_Utf8Const
*
name
)
{
if
(
!
_Jv_VerifyClassName
(
name
))
throw_class_format_error
(
"erroneous class name"
);
}
inline
void
verify_field_signature
(
_Jv_Utf8Const
*
sig
)
{
if
(
!
_Jv_VerifyFieldSignature
(
sig
))
throw_class_format_error
(
"erroneous type descriptor"
);
}
inline
void
verify_method_signature
(
_Jv_Utf8Const
*
sig
)
{
if
(
!
_Jv_VerifyMethodSignature
(
sig
))
throw_class_format_error
(
"erroneous type descriptor"
);
}
_Jv_ClassReader
(
jclass
klass
,
jbyteArray
data
,
jint
offset
,
jint
length
)
_Jv_ClassReader
(
jclass
klass
,
jbyteArray
data
,
jint
offset
,
jint
length
)
{
{
if
(
klass
==
0
||
length
<
0
||
offset
+
length
>
data
->
length
)
if
(
klass
==
0
||
length
<
0
||
offset
+
length
>
data
->
length
)
...
@@ -213,6 +241,7 @@ struct _Jv_ClassReader {
...
@@ -213,6 +241,7 @@ struct _Jv_ClassReader {
void
read_one_method_attribute
(
int
method
);
void
read_one_method_attribute
(
int
method
);
void
read_one_code_attribute
(
int
method
);
void
read_one_code_attribute
(
int
method
);
void
read_one_field_attribute
(
int
field
);
void
read_one_field_attribute
(
int
field
);
void
throw_class_format_error
(
char
*
msg
);
/** check an utf8 entry, without creating a Utf8Const object */
/** check an utf8 entry, without creating a Utf8Const object */
bool
is_attribute_name
(
int
index
,
char
*
name
);
bool
is_attribute_name
(
int
index
,
char
*
name
);
...
@@ -699,7 +728,7 @@ _Jv_ClassReader::prepare_pool_entry (int index, unsigned char this_tag)
...
@@ -699,7 +728,7 @@ _Jv_ClassReader::prepare_pool_entry (int index, unsigned char this_tag)
prepare_pool_entry
(
utf_index
,
JV_CONSTANT_Utf8
);
prepare_pool_entry
(
utf_index
,
JV_CONSTANT_Utf8
);
if
(
verify
)
if
(
verify
)
_Jv_VerifyClassN
ame
(
pool_data
[
utf_index
].
utf8
);
verify_classn
ame
(
pool_data
[
utf_index
].
utf8
);
pool_data
[
index
].
utf8
=
pool_data
[
utf_index
].
utf8
;
pool_data
[
index
].
utf8
=
pool_data
[
utf_index
].
utf8
;
pool_tags
[
index
]
=
JV_CONSTANT_Class
;
pool_tags
[
index
]
=
JV_CONSTANT_Class
;
...
@@ -742,7 +771,7 @@ _Jv_ClassReader::prepare_pool_entry (int index, unsigned char this_tag)
...
@@ -742,7 +771,7 @@ _Jv_ClassReader::prepare_pool_entry (int index, unsigned char this_tag)
||
_Jv_equalUtf8Consts
(
name
,
init_name
)))
||
_Jv_equalUtf8Consts
(
name
,
init_name
)))
/* ignore */
;
/* ignore */
;
else
else
_Jv_VerifyI
dentifier
(
pool_data
[
name_index
].
utf8
);
verify_i
dentifier
(
pool_data
[
name_index
].
utf8
);
}
}
_Jv_storeIndexes
(
&
pool_data
[
index
],
class_index
,
nat_index
);
_Jv_storeIndexes
(
&
pool_data
[
index
],
class_index
,
nat_index
);
...
@@ -1030,7 +1059,7 @@ void _Jv_ClassReader::handleField (int field_no,
...
@@ -1030,7 +1059,7 @@ void _Jv_ClassReader::handleField (int field_no,
#endif
#endif
if
(
verify
)
if
(
verify
)
_Jv_VerifyI
dentifier
(
field_name
);
verify_i
dentifier
(
field_name
);
// ignore flags we don't know about.
// ignore flags we don't know about.
field
->
flags
=
flags
&
Modifier
::
ALL_FLAGS
;
field
->
flags
=
flags
&
Modifier
::
ALL_FLAGS
;
...
@@ -1184,7 +1213,7 @@ void _Jv_ClassReader::handleMethod
...
@@ -1184,7 +1213,7 @@ void _Jv_ClassReader::handleMethod
||
_Jv_equalUtf8Consts
(
method
->
name
,
init_name
))
||
_Jv_equalUtf8Consts
(
method
->
name
,
init_name
))
/* ignore */
;
/* ignore */
;
else
else
_Jv_VerifyI
dentifier
(
method
->
name
);
verify_i
dentifier
(
method
->
name
);
_Jv_VerifyMethodSignature
(
method
->
signature
);
_Jv_VerifyMethodSignature
(
method
->
signature
);
...
@@ -1274,6 +1303,36 @@ void _Jv_ClassReader::handleMethodsEnd ()
...
@@ -1274,6 +1303,36 @@ void _Jv_ClassReader::handleMethodsEnd ()
}
}
void
_Jv_ClassReader
::
throw_class_format_error
(
char
*
msg
)
{
jstring
str
;
if
(
def
->
name
!=
NULL
)
{
jsize
mlen
=
strlen
(
msg
);
unsigned
char
*
data
=
(
unsigned
char
*
)
def
->
name
->
data
;
int
ulen
=
def
->
name
->
length
;
unsigned
char
*
limit
=
data
+
ulen
;
jsize
nlen
=
_Jv_strLengthUtf8
((
char
*
)
data
,
ulen
);
jsize
len
=
nlen
+
mlen
+
3
;
str
=
JvAllocString
(
len
);
jchar
*
chrs
=
JvGetStringChars
(
str
);
while
(
data
<
limit
)
*
chrs
++
=
UTF8_GET
(
data
,
limit
);
*
chrs
++
=
' '
;
*
chrs
++
=
'('
;
for
(;;)
{
char
c
=
*
msg
++
;
if
(
c
==
0
)
break
;
*
chrs
++
=
c
&
0xFFFF
;
}
*
chrs
++
=
')'
;
}
else
str
=
JvNewStringLatin1
(
msg
);
::
throw_class_format_error
(
str
);
}
/** This section takes care of verifying integrity of identifiers,
/** This section takes care of verifying integrity of identifiers,
signatures, field ddescriptors, and class names */
signatures, field ddescriptors, and class names */
...
@@ -1314,7 +1373,8 @@ _Jv_VerifyOne (unsigned char* ptr, unsigned char* limit, bool void_ok)
...
@@ -1314,7 +1373,8 @@ _Jv_VerifyOne (unsigned char* ptr, unsigned char* limit, bool void_ok)
return
0
;
return
0
;
}
while
(
ch
!=
';'
);
}
while
(
ch
!=
';'
);
_Jv_VerifyClassName
(
start
,
(
unsigned
short
)
(
end
-
start
));
if
(
!
_Jv_VerifyClassName
(
start
,
(
unsigned
short
)
(
end
-
start
)))
return
0
;
}
}
break
;
break
;
...
@@ -1333,7 +1393,7 @@ _Jv_VerifyOne (unsigned char* ptr, unsigned char* limit, bool void_ok)
...
@@ -1333,7 +1393,7 @@ _Jv_VerifyOne (unsigned char* ptr, unsigned char* limit, bool void_ok)
/** verification and loading procedures **/
/** verification and loading procedures **/
void
bool
_Jv_VerifyFieldSignature
(
_Jv_Utf8Const
*
sig
)
_Jv_VerifyFieldSignature
(
_Jv_Utf8Const
*
sig
)
{
{
unsigned
char
*
ptr
=
(
unsigned
char
*
)
sig
->
data
;
unsigned
char
*
ptr
=
(
unsigned
char
*
)
sig
->
data
;
...
@@ -1341,36 +1401,28 @@ _Jv_VerifyFieldSignature (_Jv_Utf8Const*sig)
...
@@ -1341,36 +1401,28 @@ _Jv_VerifyFieldSignature (_Jv_Utf8Const*sig)
ptr
=
_Jv_VerifyOne
(
ptr
,
limit
,
false
);
ptr
=
_Jv_VerifyOne
(
ptr
,
limit
,
false
);
if
(
ptr
!=
limit
)
return
ptr
==
limit
;
throw_class_format_error
(
"erroneous type descriptor"
);
}
}
void
bool
_Jv_VerifyMethodSignature
(
_Jv_Utf8Const
*
sig
)
_Jv_VerifyMethodSignature
(
_Jv_Utf8Const
*
sig
)
{
{
unsigned
char
*
ptr
=
(
unsigned
char
*
)
sig
->
data
;
unsigned
char
*
ptr
=
(
unsigned
char
*
)
sig
->
data
;
unsigned
char
*
limit
=
ptr
+
sig
->
length
;
unsigned
char
*
limit
=
ptr
+
sig
->
length
;
if
(
ptr
==
limit
)
if
(
ptr
==
limit
||
UTF8_GET
(
ptr
,
limit
)
!=
'('
)
throw_class_format_error
(
"erroneous type descriptor"
);
return
false
;
if
(
UTF8_GET
(
ptr
,
limit
)
!=
'('
)
throw_class_format_error
(
"erroneous type descriptor"
);
while
(
ptr
&&
UTF8_PEEK
(
ptr
,
limit
)
!=
')'
)
while
(
ptr
&&
UTF8_PEEK
(
ptr
,
limit
)
!=
')'
)
ptr
=
_Jv_VerifyOne
(
ptr
,
limit
,
false
);
ptr
=
_Jv_VerifyOne
(
ptr
,
limit
,
false
);
if
(
UTF8_GET
(
ptr
,
limit
)
!=
')'
)
if
(
UTF8_GET
(
ptr
,
limit
)
!=
')'
)
throw_class_format_error
(
"erroneous type descriptor"
)
;
return
false
;
// get the return type
// get the return type
ptr
=
_Jv_VerifyOne
(
ptr
,
limit
,
true
);
ptr
=
_Jv_VerifyOne
(
ptr
,
limit
,
true
);
if
(
ptr
!=
limit
)
return
ptr
==
limit
;
throw_class_format_error
(
"erroneous type descriptor"
);
return
;
}
}
/* we try to avoid calling the Character methods all the time,
/* we try to avoid calling the Character methods all the time,
...
@@ -1408,7 +1460,7 @@ is_identifier_part (int c)
...
@@ -1408,7 +1460,7 @@ is_identifier_part (int c)
return
character
->
isJavaIdentifierStart
((
jchar
)
ch
);
return
character
->
isJavaIdentifierStart
((
jchar
)
ch
);
}
}
void
bool
_Jv_VerifyIdentifier
(
_Jv_Utf8Const
*
name
)
_Jv_VerifyIdentifier
(
_Jv_Utf8Const
*
name
)
{
{
unsigned
char
*
ptr
=
(
unsigned
char
*
)
name
->
data
;
unsigned
char
*
ptr
=
(
unsigned
char
*
)
name
->
data
;
...
@@ -1417,18 +1469,18 @@ _Jv_VerifyIdentifier (_Jv_Utf8Const* name)
...
@@ -1417,18 +1469,18 @@ _Jv_VerifyIdentifier (_Jv_Utf8Const* name)
if
((
ch
=
UTF8_GET
(
ptr
,
limit
))
==-
1
if
((
ch
=
UTF8_GET
(
ptr
,
limit
))
==-
1
||
!
is_identifier_start
(
ch
))
||
!
is_identifier_start
(
ch
))
throw_class_format_error
(
"erroneous identifier"
)
;
return
false
;
while
(
ptr
!=
limit
)
while
(
ptr
!=
limit
)
{
{
if
((
ch
=
UTF8_GET
(
ptr
,
limit
))
==-
1
if
((
ch
=
UTF8_GET
(
ptr
,
limit
))
==-
1
||
!
is_identifier_part
(
ch
))
||
!
is_identifier_part
(
ch
))
throw_class_format_error
(
"erroneous identifier"
)
;
return
false
;
}
}
return
true
;
}
}
bool
void
_Jv_VerifyClassName
(
unsigned
char
*
ptr
,
_Jv_ushort
length
)
_Jv_VerifyClassName
(
unsigned
char
*
ptr
,
_Jv_ushort
length
)
{
{
unsigned
char
*
limit
=
ptr
+
length
;
unsigned
char
*
limit
=
ptr
+
length
;
...
@@ -1437,39 +1489,37 @@ _Jv_VerifyClassName (unsigned char* ptr, _Jv_ushort length)
...
@@ -1437,39 +1489,37 @@ _Jv_VerifyClassName (unsigned char* ptr, _Jv_ushort length)
if
(
'['
==
UTF8_PEEK
(
ptr
,
limit
))
if
(
'['
==
UTF8_PEEK
(
ptr
,
limit
))
{
{
if
(
!
_Jv_VerifyOne
(
++
ptr
,
limit
,
false
))
if
(
!
_Jv_VerifyOne
(
++
ptr
,
limit
,
false
))
throw_class_format_error
(
"erroneous class name"
)
;
return
false
;
else
else
return
;
return
true
;
}
}
next_level
:
next_level
:
do
{
for
(;;)
{
if
((
ch
=
UTF8_GET
(
ptr
,
limit
))
==-
1
)
if
((
ch
=
UTF8_GET
(
ptr
,
limit
))
==-
1
)
throw_class_format_error
(
"erroneous class name"
)
;
return
false
;
if
(
!
is_identifier_start
(
ch
))
if
(
!
is_identifier_start
(
ch
))
throw_class_format_error
(
"erroneous class name"
)
;
return
false
;
do
{
for
(;;)
{
if
(
ptr
==
limit
)
if
(
ptr
==
limit
)
return
;
return
true
;
else
if
((
ch
=
UTF8_GET
(
ptr
,
limit
))
==-
1
)
else
if
((
ch
=
UTF8_GET
(
ptr
,
limit
))
==-
1
)
throw_class_format_error
(
"erroneous class name"
)
;
return
false
;
else
if
(
ch
==
'.'
)
else
if
(
ch
==
'.'
)
goto
next_level
;
goto
next_level
;
else
if
(
!
is_identifier_part
(
ch
))
else
if
(
!
is_identifier_part
(
ch
))
throw_class_format_error
(
"erroneous class name"
);
return
false
;
}
while
(
true
);
}
}
while
(
true
);
}
}
}
void
bool
_Jv_VerifyClassName
(
_Jv_Utf8Const
*
name
)
_Jv_VerifyClassName
(
_Jv_Utf8Const
*
name
)
{
{
_Jv_VerifyClassName
((
unsigned
char
*
)
&
name
->
data
[
0
],
return
_Jv_VerifyClassName
((
unsigned
char
*
)
&
name
->
data
[
0
],
(
_Jv_ushort
)
name
->
length
);
(
_Jv_ushort
)
name
->
length
);
}
}
/** returns true, if name1 and name2 represents classes in the same
/** returns true, if name1 and name2 represents classes in the same
package. */
package. */
...
@@ -1548,12 +1598,6 @@ throw_class_format_error (jstring msg)
...
@@ -1548,12 +1598,6 @@ throw_class_format_error (jstring msg)
}
}
static
void
static
void
throw_class_format_error
(
char
*
msg
)
{
throw_class_format_error
(
JvNewStringLatin1
(
msg
));
}
static
void
throw_internal_error
(
char
*
msg
)
throw_internal_error
(
char
*
msg
)
{
{
JvThrow
JvThrow
...
...
libjava/include/java-interp.h
View file @
f9edddab
...
@@ -33,11 +33,11 @@ _Jv_IsInterpretedClass (jclass c)
...
@@ -33,11 +33,11 @@ _Jv_IsInterpretedClass (jclass c)
struct
_Jv_ResolvedMethod
;
struct
_Jv_ResolvedMethod
;
void
_Jv_VerifyFieldSignature
(
_Jv_Utf8Const
*
sig
);
bool
_Jv_VerifyFieldSignature
(
_Jv_Utf8Const
*
sig
);
void
_Jv_VerifyMethodSignature
(
_Jv_Utf8Const
*
sig
);
bool
_Jv_VerifyMethodSignature
(
_Jv_Utf8Const
*
sig
);
void
_Jv_VerifyClassName
(
unsigned
char
*
ptr
,
_Jv_ushort
length
);
bool
_Jv_VerifyClassName
(
unsigned
char
*
ptr
,
_Jv_ushort
length
);
void
_Jv_VerifyClassName
(
_Jv_Utf8Const
*
name
);
bool
_Jv_VerifyClassName
(
_Jv_Utf8Const
*
name
);
void
_Jv_VerifyIdentifier
(
_Jv_Utf8Const
*
);
bool
_Jv_VerifyIdentifier
(
_Jv_Utf8Const
*
);
bool
_Jv_ClassNameSamePackage
(
_Jv_Utf8Const
*
name1
,
_Jv_Utf8Const
*
name2
);
bool
_Jv_ClassNameSamePackage
(
_Jv_Utf8Const
*
name1
,
_Jv_Utf8Const
*
name2
);
void
_Jv_DefineClass
(
jclass
,
jbyteArray
,
jint
,
jint
);
void
_Jv_DefineClass
(
jclass
,
jbyteArray
,
jint
,
jint
);
void
_Jv_ResolveField
(
_Jv_Field
*
,
java
::
lang
::
ClassLoader
*
);
void
_Jv_ResolveField
(
_Jv_Field
*
,
java
::
lang
::
ClassLoader
*
);
...
...
libjava/java/lang/natClassLoader.cc
View file @
f9edddab
...
@@ -79,7 +79,9 @@ java::lang::ClassLoader::defineClass0 (jstring name,
...
@@ -79,7 +79,9 @@ java::lang::ClassLoader::defineClass0 (jstring name,
{
{
_Jv_Utf8Const
*
name2
=
_Jv_makeUtf8Const
(
name
);
_Jv_Utf8Const
*
name2
=
_Jv_makeUtf8Const
(
name
);
_Jv_VerifyClassName
(
name2
);
if
(
!
_Jv_VerifyClassName
(
name2
))
JvThrow
(
new
java
::
lang
::
ClassFormatError
(
JvNewStringLatin1
(
"erroneous class name"
)));
klass
->
name
=
name2
;
klass
->
name
=
name2
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment