equal
deleted
inserted
replaced
499 var ArrayList = Java.type("java.util.ArrayList") |
499 var ArrayList = Java.type("java.util.ArrayList") |
500 var anArrayList = new ArrayList |
500 var anArrayList = new ArrayList |
501 var anArrayListWithSize = new ArrayList(16) |
501 var anArrayListWithSize = new ArrayList(16) |
502 </code></pre> |
502 </code></pre> |
503 |
503 |
504 In the special case of inner classes, you need to use the JVM fully qualified name, meaning using $ sign in the class name: |
504 In the special case of inner classes, you can either use the JVM fully qualified name, meaning using the dollar sign in the class name, or you can use the dot: |
505 |
505 |
506 <pre><code> |
506 <pre><code> |
507 var ftype = Java.type("java.awt.geom.Arc2D$Float") |
507 var ftype = Java.type("java.awt.geom.Arc2D$Float") |
508 </code></pre> |
508 </code></pre> |
509 |
509 |
510 |
510 and |
511 However, once you retrieved the outer class, you can access the inner class as a property on it: |
511 |
|
512 <pre><code> |
|
513 var ftype = Java.type("java.awt.geom.Arc2D.Float") |
|
514 </code></pre> |
|
515 |
|
516 both work. Note however that using the dollar sign is faster, as Java.type first tries to resolve the class name as it is originally specified, and the internal JVM names for inner classes use the dollar sign. If you use the dot, Java.type will internally get a ClassNotFoundException and subsequently retry by changing the last dot to dollar sign. As a matter of fact, it'll keep replacing dots with dollar signs until it either successfully loads the class or runs out of all dots in the name. This way it can correctly resolve and load even multiply nested inner classes with the dot notation. Again, this will be slower than using the dollar signs in the name. An alternative way to access the inner class is as a property of the outer class: |
512 |
517 |
513 <pre><code> |
518 <pre><code> |
514 var arctype = Java.type("java.awt.geom.Arc2D") |
519 var arctype = Java.type("java.awt.geom.Arc2D") |
515 var ftype = arctype.Float |
520 var ftype = arctype.Float |
516 </code></pre> |
521 </code></pre> |