JAVA DEVELOPMENT KIT 7

JAVA DEVELOPMENT KIT 7

Dynamic Language Support on the Java Virtual Machine

A new bytecode and a new linkage mechanism offer better support for dynamically typed languages.

J or interpreting it. This specification and its

ava Development Kit (JDK) 7 is a prototype

This is great news for application devel-

implementation made it much easier to Platform, Standard Edition (Java SE). JDK 7

of what could be in the next release of Java

opers. The flexibility offered by dynamic lan-

create applications that include both Java introduces several key features to improve the

guages, especially scripting languages, makes

code and scripting code. Although support performance, usability, and security of the

these languages particularly attractive for

for JSR 223 has stimulated the development Java platform. Of particular interest to Java

application prototyping and experimentation

of scripting engines for the JVM, developers developers is the addition of support for Java

as well as for applications that evolve rapidly.

of these scripting engines have faced a Specification Request (JSR) 292. The addition

This flexibility stems from dynamic typing.

troublesome obstacle. of a new Java bytecode, invokedynamic, for

A language that is dynamically typed verifies

When developers write engines that method invocation, and an accompanying

at runtime that the values in an application

compile dynamically typed languages to run linkage mechanism that makes use of a new

conform to expected types. By comparison,

in the JVM, they have to satisfy the require- construct called a method handle, will enable

a statically typed language such as the Java

ments of the Java bytecode the JVM executes. implementers of compilers for dynamically

programming language does most of its type

Until now, that bytecode has been designed typed languages such as JRuby and Jython to

checking at compile time, checking the types

exclusively for statically typed languages, generate bytecode that runs extremely fast in

of variables but not of values. The Java lan-

especially in its treatment of method invoca- the Java virtual machine (JVM).

guage also allows some dynamic type checking

tion. This design has been a pain point for As a result, you should see more of your

of values, especially receivers of virtual or

script engine developers generating byte- favorite dynamically typed languages avail-

interface method calls. But even these calls

codes for method invocation. able in the Java ecosystem, along with a

require a static type for the receiver.

It is easier to write code in dynamically

performance boost in code generated by

typed languages than in statically typed

BYTECODE REQUIREMENTS FOR

dynamically typed language compilers that

languages, because the former have more-

METHOD INVOCATION

A statically typed language does its type advantage of the new invokedynamic Java

run in the JVM. This article will help you take

permissive type matching rules and can

checking before execution, at compile time. bytecode instruction for the JVM and the new

perform many type conversions automati-

What this means for a method invocation is method handle linkage mechanism.

cally. Dynamic typing is also more flexible

than static typing, because it enables pro-

that the compiler, in addition to the bytecode

grams to generate or configure types based

it generates, needs to know the type of the

DYNAMICALLY TYPED LANGUAGES

on runtime data. These behaviors can help

value returned by the method as well as the

AND THE JVM

types of any receiver or parameters specified If you said that the JVM is a program that

you create applications more quickly than

you would when coding them in a statically

in the call.

executes Java programs translated into

Consider the following Java code snippet: machine-independent bytecode, your state- ment would be correct but incomplete. The

typed language.

String s = “Hello World”; JVM does execute Java programs translated

A PROBLEM FOR DYNAMICALLY

System.out.println(s); into bytecode, but it is not limited to han-

TYPED LANGUAGES

The first step in bringing dynamic lan-

dling translated Java programs. Increasingly,

Note that the type of parameter for the JVM implementations of dynamic languages

guages to the JVM was JSR 223: Scripting

method is known. It’s a String. The println() are becoming available. These include JRuby,

for the Java Platform, a specification that

method doesn’t return a value, but if the an implementation of the Ruby program-

defined an API for accessing Java code from

code example did call a method that does ming language; Jython, an implementation

code written in dynamic scripting lan-

return a value, the type of the return value of the Python programming language; the

guages. JSR 223 also specified a framework

would need to be specified. The receiver of Groovy scripting language; and Rhino, an

for hosting scripting engines in Java appli-

the call, System.out, also has a statically implementation of JavaScript.

cations. A scripting engine is a program that

executes scripting code, either by compiling

known type, java.io.PrintStream.

Dokumen yang terkait

ALOKASI WAKTU KYAI DALAM MENINGKATKAN KUALITAS SUMBER DAYA MANUSIA DI YAYASAN KYAI SYARIFUDDIN LUMAJANG (Working Hours of Moeslem Foundation Head In Improving The Quality Of Human Resources In Kyai Syarifuddin Foundation Lumajang)

1 46 7

Analisis Komparasi Internet Financial Local Government Reporting Pada Website Resmi Kabupaten dan Kota di Jawa Timur The Comparison Analysis of Internet Financial Local Government Reporting on Official Website of Regency and City in East Java

19 819 7

FAKTOR-FAKTOR YANG BERPENGARUH TERHADAP PENDAPATAN TENAGA KERJA PENGRAJIN ALUMUNIUM DI DESA SUCI KECAMATAN PANTI KABUPATEN JEMBER The factors that influence the alumunium artisans labor income in the suci village of panti subdistrict district jember

0 24 6

The Correlation between students vocabulary master and reading comprehension

16 145 49

The correlation intelligence quatient (IQ) and studenst achievement in learning english : a correlational study on tenth grade of man 19 jakarta

0 57 61

An analysis of moral values through the rewards and punishments on the script of The chronicles of Narnia : The Lion, the witch, and the wardrobe

1 59 47

Analyzing The Content Validity Of The English Summative Tests In Vocational Schools (A Case Study In Odd Semester Of Second Year Technology Major In Tangerang Vocational Schools)

1 50 155

The Effectiveness of Computer-Assisted Language Learning in Teaching Past Tense to the Tenth Grade Students of SMAN 5 Tangerang Selatan

4 116 138

The correlation between listening skill and pronunciation accuracy : a case study in the firt year of smk vocation higt school pupita bangsa ciputat school year 2005-2006

9 128 37

PENGARUH KOSENTRASI SARI KUNYIT PUTIH (Curcuma zediaria) TERHADAP KUALITAS TELUR ASIN DITINJAU DARI AKTIVITAS ANTIOKSIDAN, TOTAL FENOL, KADAR PROTEIN DAN KADAR GARAM The Addition of White Turmeric (Curcuma zedoaria) Concentrated Base on Quality Antioxidan

1 1 8