IDL to Java 5 Mapping - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

IDL to Java 5 Mapping

Description:

IDL to Java Language Mapping Specification, August 2002, Version 1.2, The ... This would allow us to use Java 5's static import to gain access to all of the ... – PowerPoint PPT presentation

Number of Views:62
Avg rating:3.0/5.0
Slides: 13
Provided by: melani1
Category:
Tags: idl | java | mapping

less

Transcript and Presenter's Notes

Title: IDL to Java 5 Mapping


1
IDL to Java 5 Mapping
2
Perspective
  • The views expressed in this presentation are mine
    (but not necessarily mine alone) ?
  • The IDL to Java Mappingsneed updating
  • Why?...The current mappings are
  • Clunky
  • Inefficient
  • Non-intuitive

3
Specifics
  • Which version?
  • IDL to Java Language Mapping Specification,
    August 2002, Version 1.2, The Object Management
    Group
  • http//www.omg.org/cgi-bin/doc?formal/02-08-05.pdf

4
Where are the problems?
Stuff That's Missing...
5
enum
  • This one seems straight forward but
  • Currently
  • enum maps to a public class with static values
    for the enumerates and their integer (serialized)
    representation
  • Proposed
  • enum maps to a Java enum
  • Helper method would provide a conversion from the
    integer representation for deserialization and
    the standard ordinal() method would provide the
    integer for serialization

6
const
  • Currently Given the following IDL
  • const double PI 3.141592
  • const double e 2.718282
  • Yields the following Java
  • public interface PI double value 3.141592
  • public interface e double value 2.718282
  • Proposed Given the following IDL
  • const double PI 3.141592
  • const double e 2.718282
  • Would yield the following Java
  • public final class module_nameConstants
  • public final static double PI 3.141592
  • public final static double e 2.718282
  • This would allow us to use Java 5s static import
    to gain access to all of the constants for a
    given module with one fell swoop

7
sequence (1 of 3)
  • Currently Given the following IDL
  • sequence previousOrderIds
  • Yields the following Java
  • public int previousOrderIds
  • The are a couple of problems with this mapping
  • Native Java arrays are not resizeable
  • Semantics can be improved by using Java 5s
    generics
  • No possible way to control memory management (see
    next slide)

8
sequence (2 of 3)
  • So what if native Java arrays are not
    resizeable?!
  • This means that the clients of the sequence
    mapping will have to write the code below to
    increase the size of a sequence
  • int oldSize previousOrderIds.length
  • // allocate storage for the new size (larger in
    this case)
  • int previousOrderIds new intoldSize1
  • // copy over the original data
  • System.arraycopy(foo.previousOrderIds, 0,
  • previousOrderIds, 0, oldSize)
  • // reset the reference to the new int array
  • foo.previousOrderIds previousOrderIds
  • // add the order id
  • foo.previousOrderIdsoldSize someOrderId

9
sequence (3 of 3)
  • That seems like a lot of code with plenty of
    opportunity to introduce a bug
  • What if we changed the mapping from a native
    array to a generic such as
  • public List previousOrderIds
  • The code would now look like this
  • // add the new order id
  • foo.previousOrderIds.add(someOrderId)
  • Now thats better! ?
  • Additionally, real-time implementations could
    choose to pre-allocate a maximally-sized List
    object!

10
string and wstring (1 of 2)
  • Currently IDL string and wstring map to a Java
    String object.
  • Most of the time, this is perfect!
  • But, if you want to use IDL string or wstring
    attributes in a NoHeapRealTime Thread (RTSJ) then
    there may be some issues
  • The problem is that memory must be allocated when
    a String is modified since all Strings are
    immutable
  • That doesnt necessarily work well with NHRT

11
string and wstring (2 of 2)
  • Alternate Mapping Possibilities
  • java.lang.StringBuffer
  • May be too heavyweight since it has all
    synchronized methods
  • Inconvenient when doing character i/o since it
    requires calling toString() which, in turn,
    allocates memory
  • java.lang.StringBuilder
  • Ligherweight (no synchronization)
  • Same Character i/o issue as StringBuffer
  • java.lang.CharSequence
  • Provides a read-only interface to the characters
    but could be useful
  • java.nio.CharBuffer
  • This class is intended more for heavy-duty
    character i/o but should be considered

12
Stuff Thats Missing
  • Generics
  • Bounded values
  • Wouldnt it be nice to be able to declare
  • double latitude
  • Valued enumerates
  • enum StatusKind NONE 0, ALL 0xFFFFFFFF,
    INCOMPATIBLE_QOS 1, etc.
  • Or add an enumset
  • Others???
Write a Comment
User Comments (0)
About PowerShow.com