Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jshell tab completion non-instance methods

The new Java shell, jshell, allows tab completion which shows all methods available to a given instance of a class. For example, If I do...

jshell> Integer myInt = 3
myInt ==> 3

jshell> myInt. <<< + TAB >>>
byteValue()     compareTo(      doubleValue()   equals(         floatValue()   
getClass()      hashCode()      intValue()      longValue()     notify()       
notifyAll()     shortValue()    toString()      wait(

...I see all of the methods available to an Integer object. How do I see the methods and variables available to the class at large, not just an instance of the class?

like image 989
awwsmm Avatar asked Mar 10 '26 20:03

awwsmm


1 Answers

An instance of Integer will only show the instance variables and methods [ Oracle ]:

jshell> Integer j = new Integer(3)
j ==> 3

jshell> j.
byteValue()     compareTo(      doubleValue()   equals(         floatValue()   
getClass()      hashCode()      intValue()      longValue()     notify()       
notifyAll()     shortValue()    toString()      wait(

...while non-instance methods and variables can be seen by simply refraining from creating an instance:

jshell> Integer.
BYTES                    MAX_VALUE                MIN_VALUE                SIZE
TYPE                     bitCount(                class                    compare(
compareUnsigned(         decode(                  divideUnsigned(          getInteger(
hashCode(                highestOneBit(           lowestOneBit(            max(
min(                     numberOfLeadingZeros(    numberOfTrailingZeros(   parseInt(
parseUnsignedInt(        remainderUnsigned(       reverse(                 reverseBytes(
rotateLeft(              rotateRight(             signum(                  sum(
toBinaryString(          toHexString(             toOctalString(           toString(
toUnsignedLong(          toUnsignedString(        valueOf(
like image 184
awwsmm Avatar answered Mar 12 '26 09:03

awwsmm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!