View Javadoc
1   /*
2    * MIT License
3    * Copyright (c) 2006-2025 JMockit developers
4    * See LICENSE file for full license text.
5    */
6   package mockit.asm.types;
7   
8   import edu.umd.cs.findbugs.annotations.NonNull;
9   
10  import org.checkerframework.checker.index.qual.NonNegative;
11  
12  public final class ObjectType extends ReferenceType {
13      @NonNull
14      public static ObjectType create(@NonNull String internalName) {
15          return new ObjectType(internalName.toCharArray());
16      }
17  
18      /**
19       * Initializes an object reference type.
20       *
21       * @param typeDesc
22       *            a buffer containing the descriptor of the type
23       * @param off
24       *            the offset of the descriptor in the buffer
25       */
26      @NonNull
27      static ObjectType create(@NonNull char[] typeDesc, @NonNegative int off) {
28          int len = findTypeNameLength(typeDesc, off, 0);
29          return new ObjectType(typeDesc, off + 1, len - 1);
30      }
31  
32      private ObjectType(@NonNull char[] typeDesc, @NonNegative int off, @NonNegative int len) {
33          super(typeDesc, off, len);
34      }
35  
36      ObjectType(@NonNull char[] internalName) {
37          super(internalName);
38      }
39  
40      @Override
41      void getDescriptor(@NonNull StringBuilder typeDesc) {
42          typeDesc.append('L');
43          super.getDescriptor(typeDesc);
44          typeDesc.append(';');
45      }
46  
47      @NonNull
48      @Override
49      public String getClassName() {
50          return getInternalName().replace('/', '.');
51      }
52  }