Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
raphw
asm
Commits
3e0510cb
Commit
3e0510cb
authored
Mar 02, 2014
by
ebruneton
Browse files
Fixed bug #317111.
parent
a861228f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/org/objectweb/asm/ByteVector.java
View file @
3e0510cb
...
...
@@ -230,41 +230,68 @@ public class ByteVector {
if
(
c
>=
'\
001
'
&&
c
<=
'\
177
'
)
{
data
[
len
++]
=
(
byte
)
c
;
}
else
{
int
byteLength
=
i
;
for
(
int
j
=
i
;
j
<
charLength
;
++
j
)
{
c
=
s
.
charAt
(
j
);
if
(
c
>=
'\
001
'
&&
c
<=
'\
177
'
)
{
byteLength
++;
}
else
if
(
c
>
'\
u07FF
'
)
{
byteLength
+=
3
;
}
else
{
byteLength
+=
2
;
}
}
if
(
byteLength
>
65535
)
{
throw
new
IllegalArgumentException
();
}
data
[
length
]
=
(
byte
)
(
byteLength
>>>
8
);
data
[
length
+
1
]
=
(
byte
)
byteLength
;
if
(
length
+
2
+
byteLength
>
data
.
length
)
{
length
=
len
;
enlarge
(
2
+
byteLength
);
data
=
this
.
data
;
}
for
(
int
j
=
i
;
j
<
charLength
;
++
j
)
{
c
=
s
.
charAt
(
j
);
if
(
c
>=
'\
001
'
&&
c
<=
'\
177
'
)
{
data
[
len
++]
=
(
byte
)
c
;
}
else
if
(
c
>
'\
u07FF
'
)
{
data
[
len
++]
=
(
byte
)
(
0xE0
|
c
>>
12
&
0xF
);
data
[
len
++]
=
(
byte
)
(
0x80
|
c
>>
6
&
0x3F
);
data
[
len
++]
=
(
byte
)
(
0x80
|
c
&
0x3F
);
}
else
{
data
[
len
++]
=
(
byte
)
(
0xC0
|
c
>>
6
&
0x1F
);
data
[
len
++]
=
(
byte
)
(
0x80
|
c
&
0x3F
);
}
}
break
;
length
=
len
;
return
encodeUTF8
(
s
,
i
,
65535
);
}
}
length
=
len
;
return
this
;
}
/**
* Puts an UTF8 string into this byte vector. The byte vector is
* automatically enlarged if necessary. The string length is encoded in two
* bytes before the encoded characters, if there is space for that (i.e. if
* this.length - i - 2 >= 0).
*
* @param s
* the String to encode.
* @param i
* the index of the first character to encode. The previous
* characters are supposed to have already been encoded, using
* only one byte per character.
* @param maxByteLength
* the maximum byte length of the encoded string, including the
* already encoded characters.
* @return this byte vector.
*/
ByteVector
encodeUTF8
(
final
String
s
,
int
i
,
int
maxByteLength
)
{
int
charLength
=
s
.
length
();
int
byteLength
=
i
;
char
c
;
for
(
int
j
=
i
;
j
<
charLength
;
++
j
)
{
c
=
s
.
charAt
(
j
);
if
(
c
>=
'\
001
'
&&
c
<=
'\
177
'
)
{
byteLength
++;
}
else
if
(
c
>
'\
u07FF
'
)
{
byteLength
+=
3
;
}
else
{
byteLength
+=
2
;
}
}
if
(
byteLength
>
maxByteLength
)
{
throw
new
IllegalArgumentException
();
}
int
start
=
length
-
i
-
2
;
if
(
start
>=
0
)
{
data
[
start
]
=
(
byte
)
(
byteLength
>>>
8
);
data
[
start
+
1
]
=
(
byte
)
byteLength
;
}
if
(
length
+
byteLength
-
i
>
data
.
length
)
{
enlarge
(
byteLength
-
i
);
}
int
len
=
length
;
for
(
int
j
=
i
;
j
<
charLength
;
++
j
)
{
c
=
s
.
charAt
(
j
);
if
(
c
>=
'\
001
'
&&
c
<=
'\
177
'
)
{
data
[
len
++]
=
(
byte
)
c
;
}
else
if
(
c
>
'\
u07FF
'
)
{
data
[
len
++]
=
(
byte
)
(
0xE0
|
c
>>
12
&
0xF
);
data
[
len
++]
=
(
byte
)
(
0x80
|
c
>>
6
&
0x3F
);
data
[
len
++]
=
(
byte
)
(
0x80
|
c
&
0x3F
);
}
else
{
data
[
len
++]
=
(
byte
)
(
0xC0
|
c
>>
6
&
0x1F
);
data
[
len
++]
=
(
byte
)
(
0x80
|
c
&
0x3F
);
}
}
length
=
len
;
...
...
src/org/objectweb/asm/ClassWriter.java
View file @
3e0510cb
...
...
@@ -687,7 +687,8 @@ public class ClassWriter extends ClassVisitor {
sourceFile
=
newUTF8
(
file
);
}
if
(
debug
!=
null
)
{
sourceDebug
=
new
ByteVector
().
putUTF8
(
debug
);
sourceDebug
=
new
ByteVector
().
encodeUTF8
(
debug
,
0
,
Integer
.
MAX_VALUE
);
}
}
...
...
@@ -828,7 +829,7 @@ public class ClassWriter extends ClassVisitor {
}
if
(
sourceDebug
!=
null
)
{
++
attributeCount
;
size
+=
sourceDebug
.
length
+
4
;
size
+=
sourceDebug
.
length
+
6
;
newUTF8
(
"SourceDebugExtension"
);
}
if
(
enclosingMethodOwner
!=
0
)
{
...
...
@@ -917,9 +918,9 @@ public class ClassWriter extends ClassVisitor {
out
.
putShort
(
newUTF8
(
"SourceFile"
)).
putInt
(
2
).
putShort
(
sourceFile
);
}
if
(
sourceDebug
!=
null
)
{
int
len
=
sourceDebug
.
length
-
2
;
int
len
=
sourceDebug
.
length
;
out
.
putShort
(
newUTF8
(
"SourceDebugExtension"
)).
putInt
(
len
);
out
.
putByteArray
(
sourceDebug
.
data
,
2
,
len
);
out
.
putByteArray
(
sourceDebug
.
data
,
0
,
len
);
}
if
(
enclosingMethodOwner
!=
0
)
{
out
.
putShort
(
newUTF8
(
"EnclosingMethod"
)).
putInt
(
4
);
...
...
Write
Preview
Supports
Markdown
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