< prev index next >
src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java
Print this page
rev 47452 : imported patch jdk-new-asmv6.patch
*** 140,158 ****
* @param sv
* the visitor to which this adapter must delegate calls. May be
* <tt>null</tt>.
*/
public CheckSignatureAdapter(final int type, final SignatureVisitor sv) {
! this(Opcodes.ASM5, type, sv);
}
/**
* Creates a new {@link CheckSignatureAdapter} object.
*
* @param api
* the ASM API version implemented by this visitor. Must be one
! * of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
* @param type
* the type of signature to be checked. See
* {@link #CLASS_SIGNATURE}, {@link #METHOD_SIGNATURE} and
* {@link #TYPE_SIGNATURE}.
* @param sv
--- 140,158 ----
* @param sv
* the visitor to which this adapter must delegate calls. May be
* <tt>null</tt>.
*/
public CheckSignatureAdapter(final int type, final SignatureVisitor sv) {
! this(Opcodes.ASM6, type, sv);
}
/**
* Creates a new {@link CheckSignatureAdapter} object.
*
* @param api
* the ASM API version implemented by this visitor. Must be one
! * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
* @param type
* the type of signature to be checked. See
* {@link #CLASS_SIGNATURE}, {@link #METHOD_SIGNATURE} and
* {@link #TYPE_SIGNATURE}.
* @param sv
*** 173,183 ****
public void visitFormalTypeParameter(final String name) {
if (type == TYPE_SIGNATURE
|| (state != EMPTY && state != FORMAL && state != BOUND)) {
throw new IllegalStateException();
}
! CheckMethodAdapter.checkIdentifier(name, "formal type parameter");
state = FORMAL;
if (sv != null) {
sv.visitFormalTypeParameter(name);
}
}
--- 173,183 ----
public void visitFormalTypeParameter(final String name) {
if (type == TYPE_SIGNATURE
|| (state != EMPTY && state != FORMAL && state != BOUND)) {
throw new IllegalStateException();
}
! checkIdentifier(name, "formal type parameter");
state = FORMAL;
if (sv != null) {
sv.visitFormalTypeParameter(name);
}
}
*** 282,292 ****
@Override
public void visitTypeVariable(final String name) {
if (type != TYPE_SIGNATURE || state != EMPTY) {
throw new IllegalStateException();
}
! CheckMethodAdapter.checkIdentifier(name, "type variable");
state = SIMPLE_TYPE;
if (sv != null) {
sv.visitTypeVariable(name);
}
}
--- 282,292 ----
@Override
public void visitTypeVariable(final String name) {
if (type != TYPE_SIGNATURE || state != EMPTY) {
throw new IllegalStateException();
}
! checkIdentifier(name, "type variable");
state = SIMPLE_TYPE;
if (sv != null) {
sv.visitTypeVariable(name);
}
}
*** 304,314 ****
@Override
public void visitClassType(final String name) {
if (type != TYPE_SIGNATURE || state != EMPTY) {
throw new IllegalStateException();
}
! CheckMethodAdapter.checkInternalName(name, "class name");
state = CLASS_TYPE;
if (sv != null) {
sv.visitClassType(name);
}
}
--- 304,314 ----
@Override
public void visitClassType(final String name) {
if (type != TYPE_SIGNATURE || state != EMPTY) {
throw new IllegalStateException();
}
! checkClassName(name, "class name");
state = CLASS_TYPE;
if (sv != null) {
sv.visitClassType(name);
}
}
*** 316,326 ****
@Override
public void visitInnerClassType(final String name) {
if (state != CLASS_TYPE) {
throw new IllegalStateException();
}
! CheckMethodAdapter.checkIdentifier(name, "inner class name");
if (sv != null) {
sv.visitInnerClassType(name);
}
}
--- 316,326 ----
@Override
public void visitInnerClassType(final String name) {
if (state != CLASS_TYPE) {
throw new IllegalStateException();
}
! checkIdentifier(name, "inner class name");
if (sv != null) {
sv.visitInnerClassType(name);
}
}
*** 354,359 ****
--- 354,385 ----
state = END;
if (sv != null) {
sv.visitEnd();
}
}
+
+ private void checkClassName(final String name, final String msg) {
+ if (name == null || name.length() == 0) {
+ throw new IllegalArgumentException("Invalid " + msg
+ + " (must not be null or empty)");
+ }
+ for (int i = 0; i < name.length(); ++i) {
+ if (".;[<>:".indexOf(name.charAt(i)) != -1) {
+ throw new IllegalArgumentException("Invalid " + msg
+ + " (must not contain . ; [ < > or :): " + name);
+ }
+ }
+ }
+
+ private void checkIdentifier(final String name, final String msg) {
+ if (name == null || name.length() == 0) {
+ throw new IllegalArgumentException("Invalid " + msg
+ + " (must not be null or empty)");
+ }
+ for (int i = 0; i < name.length(); ++i) {
+ if (".;[/<>:".indexOf(name.charAt(i)) != -1) {
+ throw new IllegalArgumentException("Invalid " + msg
+ + " (must not contain . ; [ / < > or :): " + name);
+ }
+ }
+ }
}
< prev index next >