11 Haziran 2023 Pazar

jshell komutu - Java 9 İle Geliyor

Giriş
Açıklaması şöyle
JShell was introduced in Java 9 and is available along with other JDK tools in the JDK_HOME/bin directory. 
...
To start with JShell, browse to the JDK_HOME/bin directory in a command-line /terminal and type jshell.
1. Sınıf tanımlanabilir
2. Metod tanımlanabilir

Startup
Açıklaması şöyle
DEFAULT: loaded if no start-up script is specified.
JAVASE: imports a lot more packages.
PRINTING: like default, but adds print convenience methods.
TOOLING : Java 21 ile geliyor. Bazı şeyler hazır geliyor. Hazır gelen komutlar şunlar
TOOLING ile bazı şeyler hazır geliyor. Hazır gelen komutlar şunlar
void jar(String... args)
void javac(String... args)args)
void javadoc(String... args)
void javap(String... args)
void jdeps(String... args)
void jlink(String... args)
void jmod(String... args)
void jpackage(String... args)
Örnek - javap
Şöyle başlatırız
jshell --start DEFAULT TOOLING
Sonra şöyle yaparız
jshell> record Point(int x, int y) { }

jshell> javap(Point.class)

Classfile /tmp/TOOLING-11410713526801554514.class
  Last modified Oct 3, 2023; size 1281 bytes
  SHA-256 checksum 6f3f6c989dacd62919ce9330c7e1cc9a9511402d044198747d9a35c66a1160f4
  Compiled from "$JShell$22.java"
public final class REPL.$JShell$22$Point extends java.lang.Record
  minor version: 0
  major version: 65
  flags: (0x0031) ACC_PUBLIC, ACC_FINAL, ACC_SUPER
  this_class: #8                          // REPL/$JShell$22$Point
  super_class: #2                         // java/lang/Record
  interfaces: 0, fields: 2, methods: 6, attributes: 5
Constant pool:
   #1 = Methodref          #2.#3          // java/lang/Record."<init>":()V
   #2 = Class              #4             // java/lang/Record
   #3 = NameAndType        #5:#6          // "<init>":()V
// ... snip ...
Komutlar
Bazıları şöyle
1. /imports
2. /help
3. / list
4. /vars
5. /methods
6. / types

Hiç yorum yok:

Yorum Gönder