Nullstone Logo

COMPANY
Home
Contacts
Customers
Testimonials

PRODUCTS
Overview
NULLSTONE for C
NULLSTONE for Java
Technical Overview

SUPPORT
Release Notes
Download
PGP Information
Service Report
Write Us

INFORMATION
Performance Results
Glossary of Terms

RELATED LINKS
Compiler Connection
Compiler Jobs

Previous Up Next
Virtual Function Optimization

Java provides dynamic method dispatch. Dynamic method dispatch is the basis for Runtime polymorphism. This is also known as Late Binding and is quite timeconsuming as the resolution of the function call is deffered till the function is actually called during the runtime. Thus it is advantageous to convert virtual calls to non-virtual calls whenever possible.

Example:

In the code fragement below, the call to the virtual function can be resolved at compile time.

    
          class TestClass {
                public void VirtualGetOne() { return ; }
                public final void GetOne() { return ; }
          }
    
          class myclass {
                public void myfunction() {
                       TestClass c1 = new TestClass() ;
    		   c1.VirtualGetOne() ;
                }
          }
    
    

Below is the code fragment after Virtual Function Optimization.

    
          class TestClass {
                public void VirtualGetOne() { return ; }
                public final void GetOne() { return ; }
          }
     
          class myclass {
                public void myfunction() {
                       TestClass c1 = new TestClass() ;
                       c1.GetOne() ;
                }
          }
    

© 1990-2012 Nullstone Corporation. All Rights Reserved.