Invokedynamic Bytecode Instruction for JVM Type Checking

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

The Java Virtual Machine (JVM) currently prevents execution of bytecode generated from dynamically typed languages due to stringent pre-execution type checking by the verifier, which is not applicable to these languages as they lack explicit type declarations for method parameters.

Innovation Solution

Introducing a new bytecode instruction, 'invokedynamic', which defers stringent pre-execution type checking to runtime, allowing the JVM to execute bytecode from dynamically typed languages by relaxing type checking before execution.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If the verifier performs stringent pre-execution type checking for all method invocations, then the reliability and safety of the JVM is improved, but dynamically typed languages cannot be executed because type declarations are absent

Engineering Contradiction:
Improvesafety of JVM executionVSAvoidcompatibility with dynamically typed languages
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The patent applies local quality by differentiating the type checking behavior based on the specific bytecode instruction being executed. For 'invokevirtual' instructions, the verifier performs full type checking to ensure safety. For 'invokedynamic' instructions, the verifier applies relaxed type checking to enable dynamically typed languages. This localized differentiation allows the system to maintain high reliability for traditional Java code while achieving versatility for dynamically typed languages without compromising either aspect globally.

Inventive Principle:
Principle #3Local quality

2Reliability

If the verifier performs pre-execution type checking before bytecode execution, then the robustness and memory safety are ensured, but the execution speed is reduced due to the additional verification overhead

Engineering Contradiction:
Improverobustness and memory safetyVSAvoidexecution speed
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent segments the type checking process into two distinct paths based on the bytecode instruction type. One path handles 'invokevirtual' instructions with full pre-execution type checking to ensure memory safety. The other path handles 'invokedynamic' instructions with relaxed type checking that defers verification to runtime, thereby reducing pre-execution overhead and improving startup speed while maintaining safety through alternative means.

Inventive Principle:
Principle #1Segmentation

3Reliability

If the verifier performs full type checking for all method invocations, then the correctness of operations is ensured, but the ease of operation for dynamically typed languages is reduced due to type declaration requirements

Engineering Contradiction:
Improvecorrectness of operationsVSAvoidease of writing code in dynamically typed languages
Core Design Contradiction:
ReliabilityVSEase of operation

Solution Approach 1:

The patent introduces dynamics by making the type checking behavior flexible and adaptive rather than rigid. The verifier dynamically adjusts its checking strictness based on the bytecode instruction type. For dynamically typed languages using 'invokedynamic' instructions, the verifier applies relaxed checking that accommodates the absence of type declarations, thereby maintaining ease of operation. For statically typed Java code using 'invokevirtual' instructions, full checking is applied to ensure correctness.

Inventive Principle:
Principle #15Dynamics

Data Source

PatentUS7574700B2Supporting dynamically-typed languages in typed assembly languages
Publication Date: 2009.08.11 ORACLE AMERICAN INC
  • US7574700B2 patent drawing
  • US7574700B2 patent drawing
  • US7574700B2 patent drawing

AI summary

In accordance with one embodiment of the present invention, a technique for supporting dynamically typed languages in typed assembly languages is provided. According to one embodiment, a new bytecode instruction, “invokedynamic,” supplements “invokevirtual.” Prior to the execution of a typed assembly language program, it is determined whether a particular method-invoking instruction is a particular kind of instruction. If the instruction is of the particular kind, then the verifier refrains from performing the usual pre-execution type checking of the arguments that will be on the operand stack when the instruction is executed. Consequently, the bytecode instruction may be used to represent the invocation of a method that might not indicate formal parameter types. Because the verifier performs less stringent type checking in response to such an instruction, the JVM can execute assembly language programs that were generated based on source code that was written in a dynamically typed language.