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
asm
asm
Commits
46239d97
Commit
46239d97
authored
May 22, 2021
by
Eric Bruneton
Browse files
Allow private or protected access flags for inner classes.
parent
5495d4d1
Pipeline
#13252
passed with stage
in 6 minutes and 13 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java
View file @
46239d97
...
...
@@ -215,8 +215,7 @@ public class CheckClassAdapter extends ClassVisitor {
}
visitCalled
=
true
;
checkState
();
checkAccess
(
access
,
int
validAccessFlags
=
Opcodes
.
ACC_PUBLIC
|
Opcodes
.
ACC_FINAL
|
Opcodes
.
ACC_SUPER
...
...
@@ -227,10 +226,14 @@ public class CheckClassAdapter extends ClassVisitor {
|
Opcodes
.
ACC_ENUM
|
Opcodes
.
ACC_DEPRECATED
|
Opcodes
.
ACC_RECORD
|
Opcodes
.
ACC_MODULE
)
;
|
Opcodes
.
ACC_MODULE
;
if
(
name
==
null
)
{
throw
new
IllegalArgumentException
(
"Illegal class name (null)"
);
}
if
(
name
.
contains
(
"$"
))
{
validAccessFlags
|=
Opcodes
.
ACC_PROTECTED
|
Opcodes
.
ACC_PRIVATE
;
}
checkAccess
(
access
,
validAccessFlags
);
if
(!
name
.
endsWith
(
"package-info"
)
&&
!
name
.
endsWith
(
"module-info"
))
{
CheckMethodAdapter
.
checkInternalName
(
version
,
name
,
"class name"
);
}
...
...
asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java
View file @
46239d97
...
...
@@ -6,13 +6,13 @@
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//
notice, this list of conditions and the following disclaimer.
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//
notice, this list of conditions and the following disclaimer in the
//
documentation and/or other materials provided with the distribution.
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holders nor the names of its
//
contributors may be used to endorse or promote products derived from
//
this software without specific prior written permission.
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
...
...
@@ -78,6 +78,30 @@ public class CheckClassAdapterTest extends AsmTest implements Opcodes {
assertEquals
(
"Invalid access flags: 1048576"
,
exception
.
getMessage
());
}
@Test
public
void
testVisit_illegalPrivateClassAccessFlagForNonInnerClass
()
{
CheckClassAdapter
checkClassAdapter
=
new
CheckClassAdapter
(
null
);
Executable
visit
=
()
->
checkClassAdapter
.
visit
(
V1_1
,
Opcodes
.
ACC_PRIVATE
,
"C"
,
null
,
"java/lang/Object"
,
null
);
Exception
exception
=
assertThrows
(
IllegalArgumentException
.
class
,
visit
);
assertEquals
(
"Invalid access flags: 2"
,
exception
.
getMessage
());
}
@Test
public
void
testVisit_legalPrivateClassAccessFlagForInnerClass
()
{
CheckClassAdapter
checkClassAdapter
=
new
CheckClassAdapter
(
null
);
Executable
visit
=
()
->
checkClassAdapter
.
visit
(
V1_1
,
Opcodes
.
ACC_PRIVATE
,
"C$Inner"
,
null
,
"java/lang/Object"
,
null
);
assertDoesNotThrow
(
visit
);
}
@Test
public
void
testVisit_illegalClassName
()
{
CheckClassAdapter
checkClassAdapter
=
new
CheckClassAdapter
(
null
);
...
...
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