The Mysterious java array implementation

In java when we create an array of primitive data type
e.g long[] x = new long[10];
we can reterieve the lenght of the array using x.length. Does someone know where this variable length is declared. As in java arrays are implemented as an Objects. Even i treid to find out the class reference variable "x" belongs to, and I came to know that it is "[J" and this class implements Cloneable and Seriaziable interface. But there is no field or variable like "length".                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Java-Aspirant wrote:
. Even i treid to find out the class reference variable "x" belongs to, and I came to know that it is "[J" and this class implements Cloneable and Seriaziable interface. But there is no field or variable like "length".
If you want to use reflection on arrays, there's  [java.lang.reflect.Array|http://java.sun.com/javase/6/docs/api/java/lang/reflect/Array.html which allows you to interrogate the length pseudo-field and access elements.

Similar Messages

  • JAVA Array sizes - how to expand + See nice example code

    Hi, We are returning tables of VARCHAR, NUMBERS, BOOLEANs and
    the like to Java using PL2JAVA and Oracle Sessions. Problem I am
    having is the size of the Array's are undetermined, but it
    appears these must be set before calling package - if package
    returns more rows in tables than the calling Java arrays have,
    then it fails. If we assign too many then I guess we are using
    memory which will be wasted - important when this system could
    have 100 simultaneous users/connections.
    Has anyone got any advice - people may find the sample code below
    useful at worse.
    PACKAGE INTERFACE:
    FUNCTION ssfk_get_metadata.ssfp_get_2metadata RETURNS VARCHAR2
    Argument Name Type In/Out
    Default?
    P_USER_PERSON_ID NUMBER(10) IN
    P_SELF_SERVE_APPLICATION VARCHAR2 IN
    PT_DATA_SOURCE TABLE OF VARCHAR2(60) OUT
    PT_PROMPT TABLE OF VARCHAR2(30) OUT
    PT_DATA_TYPE TABLE OF VARCHAR2(30) OUT
    PT_DATA_LENGTH TABLE OF NUMBER OUT
    PT_DECIMAL_PLACES TABLE OF NUMBER OUT
    PT_MANDATORY_IND TABLE OF VARCHAR2(1) OUT
    PT_UCASE_IND TABLE OF VARCHAR2(1) OUT
    PT_DISPLAY_ONLY_IND TABLE OF VARCHAR2(1) OUT
    PT_WEB_LINK_CD TABLE OF VARCHAR2(10) OUT
    P_TABLE_INDEX BINARY_INTEGER OUT
    P_MESSAGE_NUM NUMBER(5) OUT
    Code example:
    public static String getApplicationMetaData (String
    strPersonID, String strApplication, Session sesSession)
    String strClientString = "";
    if (sesSession==null)
    return "CONNECTION ERROR";
    else
    Double dblUser = new Double(strPersonID);
    //initialising of IN parameters
    PDouble pdbUserPersonId = new PDouble
    (dblUser.intValue());
    PStringBuffer pstSelfServeApplication = new
    PStringBuffer (strApplication);
    //initialising of OUT parameters
    PStringBuffer pstDataSource[] = new PStringBuffer
    [intArraySize];
    PStringBuffer pstPrompt[] = new PStringBuffer
    [intArraySize];
    PStringBuffer pstDataType[] = new PStringBuffer
    [intArraySize];
    PDouble pdbDataLength[] = new PDouble [intArraySize];
    PDouble pdbDecimalPlaces[] = new PDouble
    [intArraySize];
    PStringBuffer pstMandatoryIND[] = new PStringBuffer
    [intArraySize];
    PStringBuffer pstUCaseIND[] = new PStringBuffer
    [intArraySize];
    PStringBuffer pstDisplayOnlyIND[] = new PStringBuffer
    [intArraySize];
    PStringBuffer pstWebLinkCode[] = new PStringBuffer
    [intArraySize];
    PInteger pinTableIndex = new PInteger (0);
    PDouble pdbMessageNum = new PDouble (0);
    //initialising of RETURN parameters
    PStringBuffer pstReturn = new PStringBuffer("N");
    //setting the array items sizes
    for (int i=0; i<pstDataSource.length; i++)
    pstDataSource[i] = new PStringBuffer(60);
    pstPrompt[i] = new PStringBuffer(30);
    pstDataType[i] = new PStringBuffer(30);
    pdbDataLength[i] = new PDouble(-1);
    pdbDecimalPlaces[i] = new PDouble(-1);
    pstMandatoryIND[i] = new PStringBuffer(1);
    pstUCaseIND[i] = new PStringBuffer(1);
    pstDisplayOnlyIND[i] = new PStringBuffer(1);
    pstWebLinkCode[i] = new PStringBuffer(10);
    try
    strClientString = strClientString.concat ("001");
    ssfk_get_metadata ssfAppMetaData = new
    ssfk_get_metadata (sesSession);
    strClientString = strClientString.concat ("002");
    pstReturn = ssfAppMetaData.ssfp_get_2metadata
    (pdbUserPersonId, pstSelfServeApplication, pstDataSource,
    pstPrompt, pstDataType, pdbDataLength, pdbDecimalPlaces,
    pstMandatoryIND, pstUCaseIND, pstDisplayOnlyIND, pstWebLinkCode,
    pinTableIndex, pdbMessageNum);
    strClientString = strClientString.concat ("003");
    if
    (pstReturn.stringValue().equalsIgnoreCase("Y"))
    strClientString = strClientString.concat
    ("WORKED");
    return strClientString;
    else
    return "ERROR";
    catch (Exception e)
    return strClientString + "ERROR:" + e.getMessage
    Thanks for any assistance.
    null

    Play with Java Vectors. They are automatic expanding arrays!
    Just add elements and get them later. One thing that's tricky
    is that Vectors only store and return elements as Objects so you
    have to explicitly recast them.
    -dan
    Richard Leigh (guest) wrote:
    : Hi, We are returning tables of VARCHAR, NUMBERS, BOOLEANs and
    : the like to Java using PL2JAVA and Oracle Sessions. Problem I
    am
    : having is the size of the Array's are undetermined, but it
    : appears these must be set before calling package - if package
    : returns more rows in tables than the calling Java arrays have,
    : then it fails. If we assign too many then I guess we are
    using
    : memory which will be wasted - important when this system could
    : have 100 simultaneous users/connections.
    : Has anyone got any advice - people may find the sample code
    below
    : useful at worse.
    : PACKAGE INTERFACE:
    : FUNCTION ssfk_get_metadata.ssfp_get_2metadata RETURNS VARCHAR2
    : Argument Name Type In/Out
    : Default?
    : P_USER_PERSON_ID NUMBER(10) IN
    : P_SELF_SERVE_APPLICATION VARCHAR2 IN
    : PT_DATA_SOURCE TABLE OF VARCHAR2(60) OUT
    : PT_PROMPT TABLE OF VARCHAR2(30) OUT
    : PT_DATA_TYPE TABLE OF VARCHAR2(30) OUT
    : PT_DATA_LENGTH TABLE OF NUMBER OUT
    : PT_DECIMAL_PLACES TABLE OF NUMBER OUT
    : PT_MANDATORY_IND TABLE OF VARCHAR2(1) OUT
    : PT_UCASE_IND TABLE OF VARCHAR2(1) OUT
    : PT_DISPLAY_ONLY_IND TABLE OF VARCHAR2(1) OUT
    : PT_WEB_LINK_CD TABLE OF VARCHAR2(10) OUT
    : P_TABLE_INDEX BINARY_INTEGER OUT
    : P_MESSAGE_NUM NUMBER(5) OUT
    : Code example:
    : public static String getApplicationMetaData (String
    : strPersonID, String strApplication, Session sesSession)
    : String strClientString = "";
    : if (sesSession==null)
    : return "CONNECTION ERROR";
    : else
    : Double dblUser = new Double(strPersonID);
    : //initialising of IN parameters
    : PDouble pdbUserPersonId = new PDouble
    : (dblUser.intValue());
    : PStringBuffer pstSelfServeApplication = new
    : PStringBuffer (strApplication);
    : //initialising of OUT parameters
    : PStringBuffer pstDataSource[] = new PStringBuffer
    : [intArraySize];
    : PStringBuffer pstPrompt[] = new PStringBuffer
    : [intArraySize];
    : PStringBuffer pstDataType[] = new PStringBuffer
    : [intArraySize];
    : PDouble pdbDataLength[] = new PDouble
    [intArraySize];
    : PDouble pdbDecimalPlaces[] = new PDouble
    : [intArraySize];
    : PStringBuffer pstMandatoryIND[] = new
    PStringBuffer
    : [intArraySize];
    : PStringBuffer pstUCaseIND[] = new PStringBuffer
    : [intArraySize];
    : PStringBuffer pstDisplayOnlyIND[] = new
    PStringBuffer
    : [intArraySize];
    : PStringBuffer pstWebLinkCode[] = new PStringBuffer
    : [intArraySize];
    : PInteger pinTableIndex = new PInteger (0);
    : PDouble pdbMessageNum = new PDouble (0);
    : //initialising of RETURN parameters
    : PStringBuffer pstReturn = new PStringBuffer("N");
    : //setting the array items sizes
    : for (int i=0; i<pstDataSource.length; i++)
    : pstDataSource[i] = new PStringBuffer(60);
    : pstPrompt[i] = new PStringBuffer(30);
    : pstDataType[i] = new PStringBuffer(30);
    : pdbDataLength[i] = new PDouble(-1);
    : pdbDecimalPlaces[i] = new PDouble(-1);
    : pstMandatoryIND[i] = new PStringBuffer(1);
    : pstUCaseIND[i] = new PStringBuffer(1);
    : pstDisplayOnlyIND[i] = new PStringBuffer(1);
    : pstWebLinkCode[i] = new PStringBuffer(10);
    : try
    : strClientString = strClientString.concat
    ("001");
    : ssfk_get_metadata ssfAppMetaData = new
    : ssfk_get_metadata (sesSession);
    : strClientString = strClientString.concat
    ("002");
    : pstReturn = ssfAppMetaData.ssfp_get_2metadata
    : (pdbUserPersonId, pstSelfServeApplication, pstDataSource,
    : pstPrompt, pstDataType, pdbDataLength, pdbDecimalPlaces,
    : pstMandatoryIND, pstUCaseIND, pstDisplayOnlyIND,
    pstWebLinkCode,
    : pinTableIndex, pdbMessageNum);
    : strClientString = strClientString.concat
    ("003");
    : if
    : (pstReturn.stringValue().equalsIgnoreCase("Y"))
    : strClientString = strClientString.concat
    : ("WORKED");
    : return strClientString;
    : else
    : return "ERROR";
    : catch (Exception e)
    : return strClientString + "ERROR:" +
    e.getMessage
    : Thanks for any assistance.
    null

  • How to do implement the FrameAccess.java code in my project

    Iam doing an project in java for inserting the videos into oracle9i and searching the inserted videos using the frames of the videos inserted.I have done the project to insert and search the videos.But i have been asked to put an EXTRACT button to extract all the frames of the video being inserted.Please help me to implement the FrameAccess.java coding in my existing coding.I have pasted my coding(VideoInsert.java) and FrameAccess.java(used to extract frames) coding.
    The VideoInsert.java when executed will contain browse button to choose the video file(only .mpg files) to be inserted into the database.After selecting the file and when we press open button in the Open dialog box,the video will be played in jmf player in a separate window and the filepath of the video will be included in the textbox.Now what i need is,an extract button should be placed and when it is clicked,the frames of the corresponding selected video has to be extracted in the location where the project files are stored i.e.,the FrameAccess.java coding has to be executed.
    Please help me if anyone knows how to implement the above concept.
    VideoInsert.java
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    import oracle.sql.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import oracle.sql.BLOB ;
    import symantec.itools.multimedia.ImageViewer;
    public class VideoInsert extends javax.swing.JFrame {
        private Connection con;
        private Statement st=null;
        private OracleResultSet rs=null;
        int count=0;
        int count1=0;
        ImageViewer displaywindow = new ImageViewer();
        /** Creates new form VideoInsert */
        public VideoInsert() {
            initComponents();
            imgpane.add(displaywindow);
            try {
                DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                con = DriverManager.getConnection("jdbc:oracle:oci:@","scott","tiger");
                  //con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:FIRST","scott","tiger");
                con.setAutoCommit(false);
                st =con.createStatement();
                rs=(OracleResultSet)st.executeQuery("select max(vid) from browsevideo");
                while (rs.next()) {
                    count = (rs.getInt(1) + 1);
                rs.close();
                st =con.createStatement();
                rs=(OracleResultSet)st.executeQuery("select max(imageno) from browseimage");
                while (rs.next()) {
                    count1 = (rs.getInt(1) + 1);
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            txtvid.setText(String.valueOf(count));
             VideoTypeComboBox.addItem("All");
            VideoTypeComboBox.addItem("Entertainment");
            VideoTypeComboBox.addItem("Sports");
            VideoTypeComboBox.addItem("Animation");
            VideoTypeComboBox.addItem("News");
             VideoTypeComboBox.addItem("Others");
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        private void initComponents() {//GEN-BEGIN:initComponents
            jLabel1 = new javax.swing.JLabel();
            txtvid = new javax.swing.JTextField();
            jLabel2 = new javax.swing.JLabel();
            txtvidfile = new javax.swing.JTextField();
            jLabel3 = new javax.swing.JLabel();
            txtvidinfo = new javax.swing.JTextField();
            jLabel4 = new javax.swing.JLabel();
            txtimgfile = new javax.swing.JTextField();
            vidbrowse = new javax.swing.JButton();
            imgbrowse = new javax.swing.JButton();
            jLabel5 = new javax.swing.JLabel();
            txtimgcont = new javax.swing.JTextField();
            insert = new javax.swing.JButton();
            imgpane = new javax.swing.JPanel();
            jLabel6 = new javax.swing.JLabel();
            VideoTypeComboBox = new javax.swing.JComboBox();
            getContentPane().setLayout(null);
            setTitle("VideoInsert");
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            jLabel1.setText("Video ID");
            getContentPane().add(jLabel1);
            jLabel1.setBounds(30, 80, 90, 16);
            txtvid.setEditable(false);
            getContentPane().add(txtvid);
            txtvid.setBounds(130, 80, 130, 20);
            jLabel2.setText("VideoFile");
            getContentPane().add(jLabel2);
            jLabel2.setBounds(30, 130, 70, 16);
            getContentPane().add(txtvidfile);
            txtvidfile.setBounds(130, 130, 130, 20);
            jLabel3.setText("VideoInfo");
            getContentPane().add(jLabel3);
            jLabel3.setBounds(30, 180, 80, 16);
            getContentPane().add(txtvidinfo);
            txtvidinfo.setBounds(130, 180, 130, 20);
            jLabel4.setText("TopImage");
            getContentPane().add(jLabel4);
            jLabel4.setBounds(30, 230, 70, 16);
            getContentPane().add(txtimgfile);
            txtimgfile.setBounds(130, 230, 130, 20);
            vidbrowse.setText("Browse");
            vidbrowse.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    vidbrowseActionPerformed(evt);
            getContentPane().add(vidbrowse);
            vidbrowse.setBounds(280, 130, 78, 26);
            imgbrowse.setText("Browse");
            imgbrowse.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    imgbrowseActionPerformed(evt);
            getContentPane().add(imgbrowse);
            imgbrowse.setBounds(280, 230, 78, 26);
            jLabel5.setText("ImageContent");
            getContentPane().add(jLabel5);
            jLabel5.setBounds(30, 280, 80, 16);
            getContentPane().add(txtimgcont);
            txtimgcont.setBounds(130, 280, 130, 20);
            insert.setText("Insert");
            insert.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    insertActionPerformed(evt);
            getContentPane().add(insert);
            insert.setBounds(150, 400, 81, 26);
            imgpane.setLayout(new java.awt.BorderLayout());
            getContentPane().add(imgpane);
            imgpane.setBounds(410, 120, 350, 260);
            jLabel6.setText("Video Type");
            getContentPane().add(jLabel6);
            jLabel6.setBounds(30, 340, 80, 16);
            getContentPane().add(VideoTypeComboBox);
            VideoTypeComboBox.setBounds(130, 340, 130, 25);
            pack();
            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            setSize(new java.awt.Dimension(800, 600));
            setLocation((screenSize.width-800)/2,(screenSize.height-600)/2);
        }//GEN-END:initComponents
        private void insertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_insertActionPerformed
            BLOB blb= null;
            PreparedStatement stmt = null;
            OutputStream fout=null;
            File f=null;
            FileInputStream fin=null;
            int bufferSize;
            byte[] buffer=null;
            int bytesRead = -1;
            String sfile1 = txtvidfile.getText();
            String sfile2 = txtimgfile.getText();
            String format=null;
            String format1=null;
            String videoinfo=txtvidinfo.getText();
            String imgcontent=txtimgcont.getText();
            String videoType=(String)VideoTypeComboBox.getSelectedItem();
            if(sfile1.endsWith("avi")) {
                format="avi";
            }else if(sfile1.endsWith("mpg")) {
                format="mpg";
            }else {
                format="mpg";
            if(sfile2.endsWith("jpg")) {
                format1="jpg";
            }else if(sfile2.endsWith("gif")) {
                format1="gif";
            }else {
                format1="jpg";
            if((sfile1.length()>0) && (sfile2.length()>0)) {
                try {
                    stmt=con.prepareStatement(" insert into browsevideo values (?,EMPTY_BLOB(),?,?,?)");
                    stmt.setInt(1,count);
                    stmt.setString(2,format);
                    stmt.setString(3,videoinfo);
                     stmt.setString(4,videoType);
                    stmt.executeUpdate();
                    stmt.close();
                    con.commit();
                }catch(Exception e) {
                    e.printStackTrace();
                try {
                    stmt = con.prepareStatement("Select video FROM browsevideo WHERE vid = ? for update of video");
                    stmt.setInt(1,count);
                    rs = (OracleResultSet)stmt.executeQuery();
                    rs.next();
                    blb = rs.getBLOB("video");
                    fout = blb.getBinaryOutputStream();
                    f = new File(sfile1);
                    fin = new FileInputStream(f);
                    bufferSize = blb.getBufferSize();
                    buffer = new byte[bufferSize];
                    while((bytesRead = fin.read(buffer)) != -1) {
                        fout.write(buffer, 0, bytesRead);
                    fout.flush();
                    fout.close();
                    con.commit();
                    rs.close();
                    stmt.close();
                }catch(Exception e) {
                    e.printStackTrace();
                try {
                    stmt=con.prepareStatement(" insert into browseimage values (?,?,?,EMPTY_BLOB(),?,?,?)");
                    stmt.setInt(1,count);
                    stmt.setInt(2,count1);
                    stmt.setInt(3,count1);
                    stmt.setString(4,imgcontent);
                    stmt.setString(5,format1);
                    stmt.setString(6,videoType);
                    stmt.executeUpdate();
                    stmt.close();
                    con.commit();
                }catch(Exception e) {
                    e.printStackTrace();
                try {
                    stmt = con.prepareStatement("Select image FROM browseimage WHERE imageno = ? for update of image");
                    stmt.setInt(1,count1);
                    rs = (OracleResultSet)stmt.executeQuery();
                    if(rs.next()) {
                        blb = rs.getBLOB("image");
                        fout = blb.getBinaryOutputStream();
                        f = new File(sfile2);
                        fin = new FileInputStream(f);
                        bufferSize = blb.getBufferSize();
                        buffer = new byte[bufferSize];
                        while((bytesRead = fin.read(buffer)) != -1) {
                            fout.write(buffer, 0, bytesRead);
                        fout.flush();
                        fout.close();
                        con.commit();
                        rs.close();
                    stmt.close();
                    count++;
                    count1++;
                    txtimgfile.setText("");
                    txtvidfile.setText("");
                    txtimgcont.setText("");
                    txtvidinfo.setText("");
                    txtvid.setText(String.valueOf(count));
                    JOptionPane.showMessageDialog(this,"Successfuly Completed");
                }catch(Exception e) {
                    e.printStackTrace();
        }//GEN-LAST:event_insertActionPerformed
        private void imgbrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imgbrowseActionPerformed
            ExampleFileFilter filter1 = new ExampleFileFilter();
            JFileChooser chooser = new JFileChooser();
            filter1.addExtension("jpg");
            filter1.addExtension("gif");
            filter1.setDescription("JPG,GIF Images");
            chooser.setFileFilter(filter1);
            int returnVal = chooser.showOpenDialog(this);
            if(returnVal == JFileChooser.APPROVE_OPTION) {
                txtimgfile.setText(chooser.getSelectedFile().getAbsolutePath());
                try{
                        displaywindow.setImageURL(new java.net.URL("file:"+txtimgfile.getText()));
                        displaywindow.setStyle(ImageViewer.IMAGE_SCALED_TO_FIT);
                    }catch(Exception e){
                        e.printStackTrace();
        }//GEN-LAST:event_imgbrowseActionPerformed
        private void vidbrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vidbrowseActionPerformed
           ExampleFileFilter filter2 = new ExampleFileFilter();
           JFileChooser chooser = new JFileChooser();
           filter2.addExtension("avi");
            filter2.addExtension("mpg");
            filter2.setDescription("AVI & MPG Video");
            chooser.setFileFilter(filter2);
            int returnVal = chooser.showOpenDialog(this);
            if(returnVal == JFileChooser.APPROVE_OPTION) {
                txtvidfile.setText(chooser.getSelectedFile().getAbsolutePath());
                VideoAudioPlayer vap=new VideoAudioPlayer(txtvidfile.getText());
        }//GEN-LAST:event_vidbrowseActionPerformed
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
            setVisible(false);
            dispose();
        }//GEN-LAST:event_exitForm
         * @param args the command line arguments
        /*public static void main(String args[]) {
            new VideoInsert().show();
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JButton imgbrowse;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JTextField txtvid;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JTextField txtimgcont;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JPanel imgpane;
        private javax.swing.JButton insert;
        private javax.swing.JComboBox VideoTypeComboBox;
        private javax.swing.JButton vidbrowse;
        private javax.swing.JTextField txtvidfile;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JTextField txtimgfile;
        private javax.swing.JTextField txtvidinfo;
        // End of variables declaration//GEN-END:variables
    FrameAccess.java
    import java.awt.*;
    import javax.media.*;
    import javax.media.control.TrackControl;
    import javax.media.Format;
    import javax.media.format.*;
    import java.io.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import java.awt.image.*;
    import java.util.*;
    import javax.media.util.*;
    * Sample program to access individual video frames by using a
    * "pass-thru" codec. The codec is inserted into the data flow
    * path. As data pass through this codec, a callback is invoked
    * for each frame of video data.
    public class FrameAccess implements ControllerListener {
         Processor p;
         Object waitSync = new Object();
         boolean stateTransitionOK = true;
         public boolean alreadyPrnt = false;
         * Given a media locator, create a processor and use that processor
         * as a player to playback the media.
         * During the processor's Configured state, two "pass-thru" codecs,
         * PreAccessCodec and PostAccessCodec, are set on the video track.
         * These codecs are used to get access to individual video frames
         * of the media.
         * Much of the code is just standard code to present media in JMF.
         public boolean open(MediaLocator ml) {
              try {
                   p = Manager.createProcessor(ml);
                                } catch (Exception e) {
                   System.err.println(
                        "Failed to create a processor from the given url: " + e);
                   return false;
              p.addControllerListener(this);
              // Put the Processor into configured state.
              p.configure();
              if (!waitForState(Processor.Configured)) {
                   System.err.println("Failed to configure the processor.");
                   return false;
              // So I can use it as a player.
              p.setContentDescriptor(null);
              // Obtain the track controls.
              TrackControl tc[] = p.getTrackControls();
              if (tc == null) {
                   System.err.println(
                        "Failed to obtain track controls from the processor.");
                   return false;
              // Search for the track control for the video track.
              TrackControl videoTrack = null;
              for (int i = 0; i < tc.length; i++) {
                   if (tc.getFormat() instanceof VideoFormat) videoTrack = tc[i];
                   else     tc[i].setEnabled(false);
              if (videoTrack == null) {
                   System.err.println("The input media does not contain a video track.");
                   return false;
              String videoFormat = videoTrack.getFormat().toString();
              Dimension videoSize = parseVideoSize(videoFormat);
              System.err.println("Video format: " + videoFormat);
              // Instantiate and set the frame access codec to the data flow path.
              try {
                   Codec codec[] = { new PostAccessCodec(videoSize)};
                   videoTrack.setCodecChain(codec);
              } catch (UnsupportedPlugInException e) {
                   System.err.println("The process does not support effects.");
              // Realize the processor.
              p.prefetch();
              if (!waitForState(Processor.Prefetched)) {
                   System.err.println("Failed to realise the processor.");
                   return false;
              p.start();
              return true;
         /**parse the size of the video from the string videoformat*/
         public Dimension parseVideoSize(String videoSize){
              int x=300, y=200;
              StringTokenizer strtok = new StringTokenizer(videoSize, ", ");
              strtok.nextToken();
              String size = strtok.nextToken();
              StringTokenizer sizeStrtok = new StringTokenizer(size, "x");
              try{
                   x = Integer.parseInt(sizeStrtok.nextToken());
                   y = Integer.parseInt(sizeStrtok.nextToken());
              } catch (NumberFormatException e){
                   System.out.println("unable to find video size, assuming default of 300x200");
              System.out.println("Image width = " + String.valueOf(x) +"\nImage height = "+ String.valueOf(y));
              return new Dimension(x, y);
         * Block until the processor has transitioned to the given state.
         * Return false if the transition failed.
         boolean waitForState(int state) {
              synchronized (waitSync) {
                   try {
                        while (p.getState() != state && stateTransitionOK)
                             waitSync.wait();
                   } catch (Exception e) {
              return stateTransitionOK;
         * Controller Listener.
         public void controllerUpdate(ControllerEvent evt) {
              if (evt instanceof ConfigureCompleteEvent
                   || evt instanceof RealizeCompleteEvent
                   || evt instanceof PrefetchCompleteEvent) {
                   synchronized (waitSync) {
                        stateTransitionOK = true;
                        waitSync.notifyAll();
              } else if (evt instanceof ResourceUnavailableEvent) {
                   synchronized (waitSync) {
                        stateTransitionOK = false;
                        waitSync.notifyAll();
              } else if (evt instanceof EndOfMediaEvent) {
                   p.close();
                   System.exit(0);
         * Main program
         public static void main(String[] args) {
    //          if (args.length == 0) {
    //               prUsage();
    //               System.exit(0);
    // System.out.print("masoud");
    String url = new String("file:F:\\AVSEQ01.mpg");
              if (url.indexOf(":") < 0) {
                   prUsage();
                   System.exit(0);
              MediaLocator ml;
              if ((ml = new MediaLocator(url)) == null) {
                   System.err.println("Cannot build media locator from: " + url);
                   System.exit(0);
              FrameAccess fa = new FrameAccess();
              if (!fa.open(ml))
                   System.exit(0);
         static void prUsage() {
              System.err.println("Usage: java FrameAccess <url>");
         * Inner class.
         * A pass-through codec to access to individual frames.
         public class PreAccessCodec implements Codec {
              * Callback to access individual video frames.
              void accessFrame(Buffer frame) {
                   // For demo, we'll just print out the frame #, time &
                   // data length.
                   long t = (long) (frame.getTimeStamp() / 10000000f);
                   System.err.println(
                        "Pre: frame #: "
                             + frame.getSequenceNumber()
                             + ", time: "
                             + ((float) t) / 100f
                             + ", len: "
                             + frame.getLength());
              * The code for a pass through codec.
              // We'll advertize as supporting all video formats.
              protected Format supportedIns[] = new Format[] { new VideoFormat(null)};
              // We'll advertize as supporting all video formats.
              protected Format supportedOuts[] = new Format[] { new VideoFormat(null)};
              Format input = null, output = null;
              public String getName() {
                   return "Pre-Access Codec";
              //these dont do anything
              public void open() {}
              public void close() {}
              public void reset() {}
              public Format[] getSupportedInputFormats() {
                   return supportedIns;
              public Format[] getSupportedOutputFormats(Format in) {
                   if (in == null)
                        return supportedOuts;
                   else {
                        // If an input format is given, we use that input format
                        // as the output since we are not modifying the bit stream
                        // at all.
                        Format outs[] = new Format[1];
                        outs[0] = in;
                        return outs;
              public Format setInputFormat(Format format) {
                   input = format;
                   return input;
              public Format setOutputFormat(Format format) {
                   output = format;
                   return output;
              public int process(Buffer in, Buffer out) {
                   // This is the "Callback" to access individual frames.
                   accessFrame(in);
                   // Swap the data between the input & output.
                   Object data = in.getData();
                   in.setData(out.getData());
                   out.setData(data);
                   // Copy the input attributes to the output
                   out.setFlags(Buffer.FLAG_NO_SYNC);
                   out.setFormat(in.getFormat());
                   out.setLength(in.getLength());
                   out.setOffset(in.getOffset());
                   return BUFFER_PROCESSED_OK;
              public Object[] getControls() {
                   return new Object[0];
              public Object getControl(String type) {
                   return null;
         public class PostAccessCodec extends PreAccessCodec {
              // We'll advertize as supporting all video formats.
              public PostAccessCodec(Dimension size) {
                   supportedIns = new Format[] { new RGBFormat()};
                   this.size = size;
              * Callback to access individual video frames.
              void accessFrame(Buffer frame) {
                   // For demo, we'll just print out the frame #, time &
                   // data length.
                   if (!alreadyPrnt) {
                        BufferToImage stopBuffer = new BufferToImage((VideoFormat) frame.getFormat());
                        Image stopImage = stopBuffer.createImage(frame);
                        try {
                             BufferedImage outImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
                             Graphics og = outImage.getGraphics();
                             og.drawImage(stopImage, 0, 0, size.width, size.height, null);
                             //prepareImage(outImage,rheight,rheight, null);
                             Iterator writers = ImageIO.getImageWritersByFormatName("jpg");
                             ImageWriter writer = (ImageWriter) writers.next();
                             //Once an ImageWriter has been obtained, its destination must be set to an ImageOutputStream:
                             File f = new File(frame.getSequenceNumber() + ".jpg");
                             ImageOutputStream ios = ImageIO.createImageOutputStream(f);
                             writer.setOutput(ios);
                             //Finally, the image may be written to the output stream:
                             //BufferedImage bi;
                             //writer.write(imagebi);
                             writer.write(outImage);
                             ios.close();
                        } catch (IOException e) {
                             System.out.println("Error :" + e);
                   //alreadyPrnt = true;
                   long t = (long) (frame.getTimeStamp() / 10000000f);
                   System.err.println(
                        "Post: frame #: "
                             + frame.getSequenceNumber()
                             + ", time: "
                             + ((float) t) / 100f
                             + ", len: "
                             + frame.getLength());
              public String getName() {
                   return "Post-Access Codec";
              private Dimension size;

    check out the java.lang.Runtime and java.lang.Process classes

  • [JNI Beginner] GC of Java arrays returned by the native code

    Hello all,
    I am beginning with JNI, to integrate a C library that pilots an industrial equipment, into a java UI. This library enables to exchange various proprietary PDUs (protocol data units), with the equipment, up and down (request/replies). Both requests and replies are arrays of bytes (+char*+).
    "Request" byte arrays are constructed by Java code, which passes them to the JNI code that glues with the lib. "Reply" byte arrays are returned to the Java code, which analyzes them.
    The "return reply" part is very similar to this [tutorial example|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniexamp.html] , which returns bytes read from a file. However there's something I don't understand with regard to garbage collection of the returned byte array:
    - in this stock example, the C code creates a Java byte array fills it, and simply returns it (example code stripped to highlight only the parts relevant to my question):
        jByteArray=(*env)->NewByteArray(env, size);
        (*env)->SetByteArrayRegion(env, jByteArray, 0, size, (jbyte *)sourceBytes);
        return (jByteArray);What will happen to this Java array (jByteArray) with regard to garbage collection?
    - if it's no more referenced (the example Java code just systemouts it and forgets it), will it be eligible to GC?
    - if it is referenced by a Java variable (in my case, I plan to keep a reference to several replies as the business logic requires to analyze several of them together), do regular Java language GC rules apply, and prevent eligibility of the array to GC as long as it's referenced?
    That may sound obvious, but what mixes me up is that the same tutorial describes memory issues in subsequent chapters: spécifically, the section on "passing arrays states that:
    [in the example] the array is returned to the calling Java language method, which in turn, garbage collects the reference to the array when it is no longer usedThis seems to answer "yes" to both my questions above :o) But it goes on:
    The array can be explicitly freed with the following call:
    {code} (*env)-> ReleaseByteArrayElements(env, jByteArray, (jbyte *)sourceBytes, 0);{code}Under what circumstances would one need to explicitly free jByteArray when it's about to be returned to the Java calling method? Or does this sentence apply to completely different situations (such as, when the array is +not+ returned as is to a Java method)?
    The tutorial's next section has a much-expected +memory issues+ paragraph, from which I quote:
    By default, JNI uses local references when creating objects inside a native method. This means when the method returns, the references are eligible to be garbage collected.I assume this means, +unless the references are assigned, in the Java code, to a Java variable+, right?
    If you want an object to persist across native method calls, use a global reference instead. A global reference is created from a local reference by calling NewGlobalReference on the the local reference.I assume this enables the C code to maintain a global reference to a java object even if it's not referenced anymore from the Java variables, right?
    I also checked the [JNI specification|http://download-llnw.oracle.com/javase/6/docs/technotes/guides/jni/spec/design.html#wp1242] , but this didn't clear the doubt completely:
    *Global and Local References*
    The JNI divides object references used by the native code into two categories: local and global references. Local references are valid for the duration of a native method call, and are automatically freed after the native method returns. Global references remain valid until they are explicitly freed.
    Objects are passed to native methods as local references. All Java objects returned by JNI functions are local references. The JNI allows the programmer to create global references from local references. JNI functions that expect Java objects accept both global and local references. A native method may return a local or global reference to the VM as its resultAgain I assume the intent is that Global references are meant for objects that have to survive across native calls, regardless of whether they are referenced by Java code. But what worries me is that combining both sentences end up in +All Java objects returned by JNI functions are local references (...) and are automatically freed after the native method returns.+.
    Could you clarify how to make sure that my Java byte arrays, be they allocated in C code, behave consistently with a Java array allocated in Java code (I'm familiar already with GC of "regular" Java objects)?
    Thanks in advance, and best regards,
    J.

    jduprez wrote:
    Hello all,
    I am beginning with JNI, to integrate a C library that pilots an industrial equipment, into a java UI. This library enables to exchange various proprietary PDUs (protocol data units), with the equipment, up and down (request/replies). Both requests and replies are arrays of bytes (+char*+).
    "Request" byte arrays are constructed by Java code, which passes them to the JNI code that glues with the lib. "Reply" byte arrays are returned to the Java code, which analyzes them.
    The "return reply" part is very similar to this [tutorial example|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniexamp.html] , which returns bytes read from a file. However there's something I don't understand with regard to garbage collection of the returned byte array:
    - in this stock example, the C code creates a Java byte array fills it, and simply returns it (example code stripped to highlight only the parts relevant to my question):
        jByteArray=(*env)->NewByteArray(env, size);
    (*env)->SetByteArrayRegion(env, jByteArray, 0, size, (jbyte *)sourceBytes);
    return (jByteArray);What will happen to this Java array (jByteArray) with regard to garbage collection?It will be collected when it is no longer referenced.
    The fact that you created it in jni doesn't change that.
    The array can be explicitly freed with the following call:
    (*env)-> ReleaseByteArrayElements(env, jByteArray, (jbyte *)sourceBytes, 0);Under what circumstances would one need to explicitly free jByteArray when it's about to be returned to the Java calling method? Or does this sentence apply to completely different situations (such as, when the array is not returned as is to a Java method)?
    Per what the tutorial says it is either poorly worded or just wrong.
    An array which has been properly initialized it a just a java object. Thus it can be freed like any other object.
    Per your original question that does not concern you because you return it.
    In terms of why you need to explicitly free local references.
    [http://download-llnw.oracle.com/javase/6/docs/technotes/guides/jni/spec/design.html#wp16785]
    The tutorial's next section has a much-expected memory issues paragraph, from which I quote:
    By default, JNI uses local references when creating objects inside a native method. This means when the method returns, the references are eligible to be garbage collected.I assume this means, unless the references are assigned, in the Java code, to a Java variable, right?As stated it is not precise.
    The created objects are tracked by the VM. When they are eligible to be collected they are.
    If you create a local reference and do NOTHING that creates an active reference elsewhere then when the executing thread returns to the VM then the local references are eligible to be collected.
    >
    If you want an object to persist across native method calls, use a global reference instead. A global reference is created from a local reference by calling NewGlobalReference on the the local reference.That is not precise. The scope is the executing thread. You can pass a local reference to another method without problem.
    I assume this enables the C code to maintain a global reference to a java object even if it's not referenced anymore from the Java variables, right?
    It enables access to it to be insured across multiple threads in terms of execution scope. Normally you should not use them.

  • Who an give me the java file implements LZRW  Algorithms

    pray for the java file implements LZRW Algorithms,very thanks.

    thank you all very much.
    i just use it in java, so i want change it all in pure java.
    but the Algorithms is so complex, i give up after some times.
    so i have to use jni , this is my file, it can work. but is not pure java, a pity!
    #include <stdio.h>
    #include <jni.h>
    #include "my_Tool.h"
    /* Begin of LZRW_1.C */
    #ifndef TURE
         #define BTRUE 1
    #endif
    #define UBYTE unsigned char /* Unsigned byte (1 byte ) */
    #define UWORD unsigned int /* Unsigned word (2 bytes) */
    #define ULONG unsigned long /* Unsigned longword (4 bytes) */
    #define FLAG_BYTES 4 /* Number of bytes used by copy flag. */
    #define FLAG_COMPRESS 0 /* Signals that compression occurred. */
    #define FLAG_COPY 1 /* Signals that a copyover occurred. */
    void fast_copy(p_src,p_dst,len) /* Fast copy routine. */
    UBYTE p_src,p_dst; {while (len--) *p_dst++=*p_src++;}
    void compress_LZRW_1(p_src_first,src_len,p_dst_first,p_dst_len)
    /* Input : Specify input block using p_src_first and src_len. */
    /* Input : Point p_dst_first to the start of the output zone (OZ). */
    /* Input : Point p_dst_len to a ULONG to receive the output length. */
    /* Input : Input block and output zone must not overlap. */
    /* Output : Length of output block written to p_dst_len.               /
    /* Output : Output block in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. */
    /* Output : May write in OZ=Mem[p_dst_first..p_dst_first+src_len+256-1].*/
    /* Output : Upon completion guaranteed p_dst_len<=src_len+FLAG_BYTES.  /
    UBYTE p_src_first,p_dst_first; ULONG src_len,*p_dst_len;
    #define PS p++!=s++ /* Body of inner unrolled matching loop. */
    #define ITEMMAX 16 /* Maximum number of bytes in an expanded item. */
    {UBYTE *p_src=p_src_first,*p_dst=p_dst_first;
    UBYTE *p_src_post=p_src_first+src_len,*p_dst_post=p_dst_first+src_len;
    UBYTE *p_src_max1=p_src_post-ITEMMAX,*p_src_max16=p_src_post-16*ITEMMAX;
    UBYTE *hash[4096],*p_control; UWORD control=0,control_bits=0;
    *p_dst=FLAG_COMPRESS; p_dst+=FLAG_BYTES; p_control=p_dst; p_dst+=2;
    while (BTRUE)
    {UBYTE *p,*s; UWORD unroll=16,len,index; ULONG offset;
        if (p_dst>p_dst_post) goto overrun;
        if (p_src>p_src_max16)
          {unroll=1;
           if (p_src>p_src_max1)
             {if (p_src==p_src_post) break; goto literal;}}
    begin_unrolled_loop:
    index=((40543*((((p_src[0]<<4)^p_src[1])<<4)^p_src[2]))>>4) & 0xFFF;
    p=hash[index]; hash[index]=s=p_src; offset=s-p;
    if (offset>4095 || p<p_src_first || offset==0 || PS || PS || PS)
    {literal: *p_dst++=*p_src++; control>>=1; control_bits++;}
    else
    {PS || PS || PS || PS || PS || PS || PS ||
              PS || PS || PS || PS || PS || PS || s++; len=s-p_src-1;
              *p_dst++=((offset&0xF00)>>4)+(len-1); *p_dst++=offset&0xFF;
              p_src+=len; control=(control>>1)|0x8000; control_bits++;}
    end_unrolled_loop: if (--unroll) goto begin_unrolled_loop;
    if (control_bits==16)
    {*p_control=control&0xFF; *(p_control+1)=control>>8;
    p_control=p_dst; p_dst+=2; control=control_bits=0;}
    control>>=16-control_bits;
    p_control++=control&0xFF; p_control++=control>>8;
    if (p_control==p_dst) p_dst-=2;
    *p_dst_len=p_dst-p_dst_first;
    return;
    overrun: fast_copy(p_src_first,p_dst_first+FLAG_BYTES,src_len);
    p_dst_first=FLAG_COPY; p_dst_len=src_len+FLAG_BYTES;
    void decompress_LZRW_1(p_src_first,src_len,p_dst_first,p_dst_len)
    /* Input : Specify input block using p_src_first and src_len. */
    /* Input : Point p_dst_first to the start of the output zone. */
    /* Input : Point p_dst_len to a ULONG to receive the output length. */
    /* Input : Input block and output zone must not overlap. User knows */
    /* Input : upperbound on output block length from earlier compression. */
    /* Input : In any case, maximum expansion possible is eight times. */
    /* Output : Length of output block written to p_dst_len.               /
    /* Output : Output block in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. */
    /* Output : Writes only in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. */
    UBYTE p_src_first, p_dst_first; ULONG src_len, *p_dst_len;
    {UWORD controlbits=0, control;
    UBYTE *p_src=p_src_first+FLAG_BYTES, *p_dst=p_dst_first,
           *p_src_post=p_src_first+src_len;
    if (*p_src_first==FLAG_COPY)
       {fast_copy(p_src_first+FLAG_BYTES,p_dst_first,src_len-FLAG_BYTES);
        *p_dst_len=src_len-FLAG_BYTES; return;}
    while (p_src!=p_src_post)
    {if (controlbits==0)
          {control=*p_src++; control|=(*p_src++)<<8; controlbits=16;}
    if (control&1)
    {UWORD offset,len; UBYTE *p;
           offset=(*p_src&0xF0)<<4; len=1+(*p_src++&0xF);
           offset+=*p_src++&0xFF; p=p_dst-offset;
           while (len--) *p_dst++=*p++;}
    else
    p_dst++=p_src++;
    control>>=1; controlbits--;
    *p_dst_len=p_dst-p_dst_first;
    JNIEXPORT jbyteArray JNICALL Java_my_Tool_compress
    (JNIEnv * env, jclass cls, jbyteArray src) {
         jsize srcLen ;
         jbyte* ba;
         int zipLen;
         char zipBuf[4096];
         jbyteArray ret ;
         srcLen = (*env)->GetArrayLength(env,src);
         printf("the length is %d \n", srcLen);
         ba = (*env)->GetByteArrayElements(env,src,JNI_FALSE);
         compress__LZRW_1(ba,srcLen,zipBuf,&zipLen);
         printf("ret len is : %d", zipLen);
         ret = (*env)->NewByteArray(env,zipLen);
         (*env)->SetByteArrayRegion(env,ret,0,zipLen,(jbyte*)zipBuf);
         return ret;
    JNIEXPORT jbyteArray JNICALL Java_my_Tool_uncompress
    (JNIEnv * env, jclass cls, jbyteArray src) {
         jsize srcLen ;
         jbyte* ba;
         int unzipLen;
         char unzipBuf[4096];
         jbyteArray ret ;
         srcLen = (*env)->GetArrayLength(env,src);
         printf("the length is %d \n", srcLen);
         ba = (*env)->GetByteArrayElements(env,src,JNI_FALSE);
         decompress__LZRW_1(ba,srcLen,unzipBuf,&unzipLen);
         printf("ret len is : %d\n", unzipLen);
         ret = (*env)->NewByteArray(env,unzipLen);
         (*env)->SetByteArrayRegion(env,ret,0,unzipLen,(jbyte*)unzipBuf);
         return ret;
    }

  • The CustomDatumExample.java only works if the Employee object has 2 attributes.

    The CustomDatumExample.java only works
    if the Employee object has 2 attributes -
    (EmpName and EmpNo). If I try to add
    another attribute to the Employee object I get java.lang.ArrayIndexOutOfBoundsException: 2 on the getAttr3 method.
    Anyone know why? Thanks.
    Employee object
    CREATE TYPE employee AS OBJECT
    (empname VARCHAR2(50), empno INTEGER,
    attr3 VARCHAR2(50));
    Custom object class
    public class Employee implements CustomDatum, CustomDatumFactory
    public static final String SQLNAME = "EMPLOYEE";
    public static final int SQLTYPECODE = OracleTypes.STRUCT;
    MutableStruct _struct;
    static int[] _sqlType =
    12, 4
    static CustomDatumFactory[] _factory = new CustomDatumFactory[3];
    static final Employee _EmployeeFactory = new Employee();
    public static CustomDatumFactory getFactory()
    return _EmployeeFactory;
    /* constructor */
    public Employee()
    struct = new MutableStruct(new Object[3], sqlType, _factory);
    /* CustomDatum interface */
    public Datum toDatum(OracleConnection c) throws SQLException
    return struct.toDatum(c, SQL_NAME);
    /* CustomDatumFactory interface */
    public CustomDatum create(Datum d, int sqlType) throws SQLException
    if (d == null) return null;
    Employee o = new Employee();
    o._struct = new MutableStruct((STRUCT) d, sqlType, factory);
    return o;
    /* accessor methods */
    public String getEmpname() throws SQLException
    { return (String) _struct.getAttribute(0); }
    public void setEmpname(String empname) throws SQLException
    { _struct.setAttribute(0, empname); }
    public Integer getEmpno() throws SQLException
    { return (Integer) _struct.getAttribute(1); }
    public void setEmpno(Integer empno) throws SQLException
    { _struct.setAttribute(1, empno); }
    public String getAttr3() throws SQLException
    { return (String) _struct.getAttribute(2); }
    public void setAttr3(String attr3) throws SQLException
    { _struct.setAttribute(2, attr3); }
    }

    You also need to add an appropriate element to the _sqlType array.
    In practice, it is easiest to have JPublisher regenerate the CustomDatum class when you have changed your object type definition:
    jpub -user=scott/tiger -sql=EMPLOYEE:Employee

  • Java arrays contiguous in memory?

    are java arrays always contiguous in memory? or how does java save his arrays?
    i need to know because i wrote an algorithm with a lot of array length changing, and i wonder if it consumes a lot or not, maybe java uses virtual memory arrays like those here :
    http://developers.sun.com/solaris/articles/virtual_memory_arrays.html
    any answer is welcome,
    Nck.

    The internal layout of objects (including arrays) is explicitly undefined by the JVM standard:
    http://java.sun.com/docs/books/vmspec/2nd-edition/html/Overview.doc.html#16066
    So you can't assume that arrays are implemented in any particular way on any given JVM. But the Get<Type>ArrayElements JNI functions can give you a clue about it for the current JVM.
    But I don't really understand the background of the question. What do you mean by "a lot of array length changing"? Java arrays can't be resized, whether from bytecode or JNI.
    -slj-

  • Any way to Initialize Java Array to start with 1

    Hi Friends,
    Is there anyway to initialize the java array with starting with 1 instead of normal 0.
    Thanks and Regards.
    JG

    JamesGeorge wrote:
    Hi Jacob,
    Thanks for you time..
    Coding like 1 - n will make everything uneasy, I find in other languages like vbscript,lotusscript it can be done..so just a thought to check in Java too..
    Is there any valid reason for Java/Sun guys to start the arrays,vectors and other collections with 0
    Thanks
    JJShort answer: Java is a C-based language, and C arrays are zero-based so the rest are also zero-based for consistency.
    Long answer: Arrays are implemented as contiguous areas of memory starting from a certain memory address, and loading from a zero-based array implies one less CPU instruction than loading from a one-based array.
    Zero-based:
    - LOAD A, ArrayAddress
    - LOAD B, Index
    - MUL B, ElementSize
    - ADD A, B
    - LOAD (A)
    One-based:
    - LOAD A, ArrayAddress
    - LOAD B, Index
    - ADD B, -1
    - MUL B, ElementSize
    - ADD A, B
    - LOAD (A)

  • What are the opcodes that put vars on the local frame array? Remove them?

    Does anyone know of a reference that lists all the opcodes that put a local variable in the local frame array (like ASTORE, BIPUSH, etc) and all the ones that remove them (like POP, ALOAD, etc)?

    BIPUSH doesn't affect the frame, it pushes a value onto the operand stack. The distinction may be subtle, but it's
    important since the JVM is a stack-based architecture (in other words, if you don't make the distinction, than your
    list contains [almost] all of the JVM opcodes).You're right. So then, what exactly are POP, DUP, etc doing? Are they taking from the frame?First thing to remember is that the frame and operand stack are logically different: the frame contains method parameters and local variables, while the operand stack is used for intermediate results. They may be implemented using a single processor stack (in X86 terms, the BP register would point to the start of the frame, while pushes and pops would modify the SP), but don't have to be. I think the JVM spec even talks about storing frames in the heap.
    Here's an example:
    public static int foo(int a, int b)
        int c = a + b;
        int d = (c + c) * 5;
        return d;
    }Running javap -c to show the bytecodes, we get this:
    public static int foo(int, int);
      Code:
       0:   iload_0
       1:   iload_1
       2:   iadd
       3:   istore_2
       4:   iload_2
       5:   iload_2
       6:   iadd
       7:   iconst_5
       8:   imul
       9:   istore_3
       10:  iload_3
       11:  ireturnThe two method parameters, a and b, are stored in the frame in slot 0 and 1 (if this were an instance method, slot 0 would contain "this"). They get pushed onto the stack using the iload opcode (the normal version of this opcode takes a second byte index into the frame; to minimize code size, the JVM has alternate versions of most frame-access opcodes that are hardcoded for a specific low-numbered slots).
    After the loads, the stack will contain the values held in b and a; the iadd instruction adds these together, leaving the result on the stack. The istore_2 removes the topmost value from the operand stack, and stores it in the frame (in the slot assigned to variable "c").
    To your question about dup and so forth, I was hoping to demonstrate that with the repeated reference to variable "c"; instead, the compiler translated that into the two iload operations (opcodes 4 and 5). I suppose it makes sense, but it shows just how little optimization the compiler attempts to do -- instead, it relies on Hotspot being smart enough to optimize hardware accesses.
    The iconst_5 opcode is another example of something that affects the operand stack but not the frame: it pushes a hardcoded constant value onto the stack.
    It's also another case where the JVM defines several opcodes that do the same thing: the iconst_n for values -1 to 5, bipush for values that are outside this range but still smaller than a byte, sipush for values that will fit into a short, and ldc for everything else. The goal is efficient code generation: 1-3 bytes for most of the integer values that you're likely to load. The ldc opcode is interesting in its own right: it does a lookup into a per-class table to find the value to push. Not very efficient in terms of CPU cycles and memory access (although it can be inlined by Hotspot), but again efficient from a bytecode perspective: if you're loading a large constant, there's at least a chance that you'll be loading it multiple times.
    Chapter 6 of the VM spec lists all the opcodes, and I seem to remember groupings by purpose: http://
    java.sun.com/docs/books/jvms/second_edition/html/Instructions.doc.htmlUnfortunately, it doesn't quite do that. They're mostly all in the same place on the summary page but not quite all. (For example, the array ones were in a separate place) And the link you posted lists them only alphabetically.Yeah, but jverd posted the link to section 3.11, which groups the opcodes. You probably want 3.11.2: http://java.sun.com/docs/books/jvms/second_edition/html/Overview.doc.html#6348
    Which leads to the more interesting question: why?

  • How an array implements an interface?

    Section 5.5 of JLS (dealing with casting conversions) explains something like this:
    When an interface type S is cast to an array type T,
    "then T must implement S, or a compile-time error occurs. "
    I could not understand how an array can be made to implement an interface.
    I guessed it means that the component type of array implements the interface, and prepared the following test code. It doesn't compile.
    interface S{  }
    class C implements S{ }
    class Test {
    public static void main(String[] args) {
         C[] ac = new C[100];
         S s = new C();
         C[] ac1 = (C[])s; //doesn't compile
         System.out.println(ac1.length);
    Would someone open my eyes? Thank you

    dmbdmb Your correction compiled my code. But I was not looking for that, because the corrected code casts an array type to array type. Anyway, thanks.
    jverdYou are the man. Now I got it. Thank you.
    I think I will have to remember your simplified rule (Then S must be Serializable or Cloneable) rather than the JLS' rule. With your rule, I can write a test code like this, which compiles, and which shows that an interface type can be cast to array type.
    import java.awt.Point;
    import java.io.Serializable;
    class Test {
            public static void main(String[] args) {
               Point[] pa = new Point[100]; //any array of reference type
               Serializable s = new String("test");
               Point[] pa1 = (Point[])s; //compiles, though invalid at runtime
    }

  • OIC: Need to find the Source Code for the YTDSummary.java file

    Hi All,
    We have 11.5.10 implemention and we are using the OIC(Incentive Compensation) Application. In the Report Module for the Year-To-Date Summary we need look for the Java Source Code.The cnytdsum.jsp file call the YTDSummary.java file. We have teh following question
    1. How we can get the Java Source Code and where and which directory we need to look into?
    2. Let say if we need to customize the java file how we can do that?
    3. where and which directory we have to complie the java file?
    Highly appreciate for any pointers
    Thanks,
    Johnson.

    But those must be platform dependant, not really that
    interesting to look at. I have never felt any need to
    look at those at least.Wake up and smell the coffee, abbie! I read the source code all the time and constantly tell my students to do that, too.
    1. Java source code is not platform dependent. The original poster wanted to look at linked list code, how could that be platform dependent?
    2. It is the implementation of the SDK APIs, so by definition it is implementation dependent code, liable to change in a later version. So don't assume anything beyond what is claimed in the API documentation. However, sometimes the documentation is incomplete or ambiguous to you, and reading the source can provide some insight, however implementation dependent. (Light a candle or curse the darkness.)
    3. Why read source code? It's a good way to learn how to program. You see something in the API and ask: how'd they do that? Or you realize you want to do something broadly similar, but you can't reuse the source code.
    For example, Images are not Serializable, but suppose you want a small image that is part of an object to be serialized with the rest of the object without too much fuss (ie, without using javax.imageio). You notice ImageIcon is serializable, so you use it. (An ImageIcon has-an Image.) Then you wonder: how'd they do that? You read the source and then you know.
    You live, you learn,
    Nax

  • What is the mystery with UNIXProcessReaper??

    I am making this post partially to actually get its name on to the net (Google has zero hits on UNIXProcessReaper) but mainly to garner some insight into a major problem I have "sort of" solved. OK, so I'm a Java newbee, having to maintain a bunch of dodgy Java code running on Linux (Redhat 7.2) with Java 2 Runtime Environment, Standard Edition (build 1.4.0-b92), Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode).
    Typically the application chews up about 2 - 4% of the cpu when running. I re-wrote the logging facility and (stupidly it seems) removed the BufferedOutputStream from the file I/O, which caused the application to go crazy, sitting on 100% of cpu usage for 5 to 10 seconds at a time. Note that the total logging load would not be more than 300 bytes / second.
    The mystery for me is that the profiler showed the following activity during these spasms:
    CPU SAMPLES BEGIN (total = 117209) Mon Oct 21 16:43:23 2002
    rank self accum count trace method
    1 32.74% 32.74% 47417 4636 java.lang.UNIXProcessReaper.run
    2 32.73% 65.47% 47907 3227 sun.awt.motif.MToolkit.run
    3 1.64% 67.11% 1922 30291 sun.awt.font.FontDesignMetrics.handleCharWidth
    4 0.32% 67.43% 370 30187 sun.awt.font.NativeFontWrapper.getCharMetrics
    5 0.24% 67.67% 285 30292 javax.swing.plaf.basic.BasicLabelUI.getPreferredSize
    6 0.23% 67.90% 271 30284 sun.awt.SunToolkit.getFontMetrics
    7 0.22% 68.13% 261 30285 java.awt.font.FontRenderContext.getTransform
    8 0.22% 68.34% 254 30286 sun.awt.font.FontDesignMetrics.<init>
    but nothing gives me any help on UNIXProcessReaper, it is not mentioned in any Java documentation, and as I started out saying, it has zero hits on Google. I guess it is (or part of) the garbage collector. BTW, my intuition tells me the application has some other fundamental problem lying just under the surface, probably to do with how it uses swing, and I just dug deep enough to expose it.
    Can anyone shed any light on why unbuffered I/O would cause such problems and why the UNIXProcessReaper has not been mentioned by any other lost newbee?
    Cheers,
    Scott.

    From the docs :
    "By setting up such an output stream, an application can write bytes to the underlying output stream without necessarily causing a call to the underlying system for each byte written. The data is written into an internal buffer, and then written to the underlying stream if the buffer reaches its capacity, the buffer output stream is closed, or the buffer output stream is explicitly flushed. "
    So this means that unnecessary calls are removed during writting. Instead of making multiple writes when you receive data, a write is only done when the buffer is full. That's why it is more efficient. The java tutorial also states this in this url : http://java.sun.com/docs/books/tutorial/essential/io/datasinks.html
    If you are a newbie who is worried too much about logging, I'd suggest you take a look at the log4j project. Check it out at
    http://jakarta.apache.org

  • How to use the Public Java API

    Is it possible to use the Public Java API to write a custom transformation in Java and use this in OWB. i.e. Say I have a Dateofbirth field in my source database and an Agegroup field in the target database, and I write a transformation in Java to take the Dateofbirth as an input parameter to the method and calculate the Agegroup e.g. 25-30, and return it from this method which then populates the Agegroup field in the target database. If so, how do I go about this?

    Martin,
    In general, yes you could... but you do not need to. You could use the UI to implement this requirement. The public Java API is there for you to manipulate metadata. How you implement your system, is independent of that.
    The way you would go about the case you just mentioned... you would write the Java code, deploy it into the database, wrap it in a PL/SQL procedure or function, and call it from OWB.
    Would this be a good idea...? I think no. Unless you have very complicated calculations that can only be performed in Java, I strongly encourage you use the PL/SQL language. Reason being: transformation will be much faster, because there is no need to translate PL/SQL into Java and back again.
    Hope this helps,
    Mark.

  • Mapping Java Arrays

    I was given an object model generated by an apache product, Axis. The generated java files use the Java Array in the following fashion:
    Class Zoo {
    private ArrayOfAnimals animals;
    // … public get/set methods cut
    Class ArrayOfAnimals {
    private Animal animals[];
    // … public get/set methods cut
    Class Animal {
    private String name;
    // … public get/set methods cut
    I was tasked with mapping the one-to-many relationship between zoo and an array of animals using the Animal array. I can’t find a mapping in TopLink to do this type of association. I am NOT allowed to modify the generated source code. I may be able to extend the generated classes, and perhaps provide a different superclass.
    I am allowed to create the relational model for these domain classes. Can anyone help with this type of mapping?
    Thanks

    TopLink does not directly support arrays as the mapping type for a collection, only collection types that support the Collection and Map interfaces.
    In general it seems odd to use an array instead of a Java collection which would be much more efficient (in terms of adding and removing) and much more functional. I would definitely suggest changing the generated code, or the way the code is generated if at all possible.
    The easiest way to map the array in TopLink would be the use get/set methods for the 1-m mapping on the Zoo class that converted the array to/from a Collection.
    i.e. something like,
    public List getAnimalsList() {
    return new Arrays.asList(animals.animals);
    public void setAnimalsList(List list) {
    animals.animals = (Animal[]) list.toArray();
    In general TopLink uses its ContainerPolicy class to handle collections. It may also be possible (but advanced) to write a custom container policy for your 1-m mapping that handles arrays.

  • How deploy the EJB in security on the Sun Java System Application Server 9?

    I hava deploied a simple Hello EJB Object on PE 9(Sun Java System Application Server Platform Edition 9). I can use this EJB object without user name an password On any client. See the following code section:
         public static void main(String[] args) {
              try{
                   Properties props = System.getProperties();
                   props.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.enterprise.naming.SerialInitContextFactory");
                   props.put(Context.PROVIDER_URL,"iiop://localhost:3700");
                   Context ctx = new InitialContext(props);
                   Hello h = (Hello) ctx.lookup("ejb/test/Hello");
                   System.out.println(h.sayHello());
              }catch(Exception e){
                   e.printStackTrace();
    Please tell me how deploy the EJB in security on the Sun Java System Application Server 9? So that, The client must set the user name and password when lookup the ejb object. Like the following:
    props.put(Context.SECURITY_PRINCIPAL,"admin")
    props.put(Context.SECURITY_CREDENTIALS,"1234");

    Guys,
    I too have the same issue. If anyone has an answer, please let me know.
    Is this GlassFish problem? or Prgram issue?
    Find below the source code
    package TransactionSecurity.bean;
    import javax.annotation.Resource;
    import javax.annotation.security.DeclareRoles;
    import javax.annotation.security.PermitAll;
    import javax.annotation.security.RolesAllowed;
    import javax.ejb.Remote;
    import javax.ejb.SessionContext;
    import javax.ejb.Stateless;
    import javax.ejb.TransactionAttribute;
    import javax.ejb.TransactionAttributeType;
    @Stateless
    @Remote(TSCalculator.class)
    @DeclareRoles({"student", "teacher"})
    public class TSCalculatorBean implements TSCalculator {
         private @Resource SessionContext ctx;
         @PermitAll
    //     @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
         public int add(int x, int y) {
              System.out.println("CalculatorBean.add  Caller Principal:" + ctx.getCallerPrincipal().getName());
              return x + y;
         @RolesAllowed( { "student" })
         public int subtract(int x, int y) {
              System.out.println("CalculatorBean.subtract  Caller Principal:" + ctx.getCallerPrincipal().getName());
              System.out.println("CalculatorBean.subtract  isCallerInRole:" + ctx.isCallerInRole("student"));
              return x - y;
         @RolesAllowed( { "teacher" })
         public int divide(int x, int y) {
              System.out.println("CalculatorBean.divide  Caller Principal:" + ctx.getCallerPrincipal().getName());
              System.out.println("CalculatorBean.divide  isCallerInRole:" + ctx.isCallerInRole("teacher"));
              return x / y;
    package TransactionSecurity.bean;
    import javax.ejb.Remote;
    @Remote
    public interface TSCalculator {
            public int add(int x, int y);
            public int subtract(int x, int y);
            public int divide(int x, int y);
    package TransactionSecurity.client;
    import java.util.Properties;
    import javax.ejb.EJBAccessException;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import TransactionSecurity.bean.TSCalculator;
    public class TSCalculatorClient {
         public static void main(String[] args) throws Exception {
              // Establish the proxy with an incorrect security identity
              Properties env = new Properties();
              env.setProperty(Context.SECURITY_PRINCIPAL, "kabir");
              env.setProperty(Context.SECURITY_CREDENTIALS, "validpassword");
            env.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.sun.appserv.naming.S1ASCtxFactory");
            env.setProperty(Context.PROVIDER_URL,"iiop://127.0.0.1:3700");
            env.setProperty("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");
            env.setProperty("java.naming.factory.url.pkgs","com.sun.enterprise.naming");
            env.setProperty("java.naming.factory.state","com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
            env.setProperty("org.omg.CORBA.ORBInitialHost", "127.0.0.1");
            env.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
              InitialContext ctx = new InitialContext(env);
              TSCalculator calculator = null;
              try {
                   calculator = (TSCalculator) ctx.lookup(TSCalculator.class.getName());
              } catch (Exception e) {
                   System.out.println ("Error in Lookup");
                   e.printStackTrace();
                   System.exit(1);
              System.out.println("Kabir is a student.");
              System.out.println("Kabir types in the wrong password");
              try {
                   System.out.println("1 + 1 = " + calculator.add(1, 1));
              } catch (EJBAccessException ex) {
                   System.out.println("Saw expected SecurityException: "
                             + ex.getMessage());
              System.out.println("Kabir types in correct password.");
              System.out.println("Kabir does unchecked addition.");
              // Re-establish the proxy with the correct security identity
              env.setProperty(Context.SECURITY_CREDENTIALS, "validpassword");
              ctx = new InitialContext(env);
              calculator = (TSCalculator) ctx.lookup(TSCalculator.class.getName());
              System.out.println("1 + 1 = " + calculator.add(1, 1));
              System.out.println("Kabir is not a teacher so he cannot do division");
              try {
                   calculator.divide(16, 4);
              } catch (javax.ejb.EJBAccessException ex) {
                   System.out.println(ex.getMessage());
              System.out.println("Students are allowed to do subtraction");
              System.out.println("1 - 1 = " + calculator.subtract(1, 1));
    }The user kabir is created in the server and this user belongs to the group student.
    Also, I have enabled the "Default Principal To Role Mapping"
    BTW, I'm able to run other EJB3 examples [that does'nt involve any
    security features] without any problems.
    Below is the ERROR
    Error in Lookupjavax.naming.NamingException: ejb ref resolution error for remote business interfaceTransactionSecurity.bean.TSCalculator [Root exception is java.rmi.AccessException: CORBA NO_PERMISSION 0 No; nested exception is:
         org.omg.CORBA.NO_PERMISSION: ----------BEGIN server-side stack trace----------
    org.omg.CORBA.NO_PERMISSION:   vmcid: 0x0  minor code: 0  completed: No
         at com.sun.enterprise.iiop.security.SecServerRequestInterceptor.handle_null_service_context(SecServerRequestInterceptor.java:407)
         at com.sun.enterprise.iiop.security.SecServerRequestInterceptor.receive_request(SecServerRequestInterceptor.java:429)
         at com.sun.corba.ee.impl.interceptors.InterceptorInvoker.invokeServerInterceptorIntermediatePoint(InterceptorInvoker.java:627)
         at com.sun.corba.ee.impl.interceptors.PIHandlerImpl.invokeServerPIIntermediatePoint(PIHandlerImpl.java:530)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.getServantWithPI(CorbaServerRequestDispatcherImpl.java:406)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:224)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
         at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
         at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
    ----------END server-side stack trace----------  vmcid: 0x0  minor code: 0  completed: No]
         at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:425)
         at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:74)
         at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
         at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:403)
         at javax.naming.InitialContext.lookup(InitialContext.java:351)
         at TransactionSecurity.client.TSCalculatorClient.main(TSCalculatorClient.java:35)
    Caused by: java.rmi.AccessException: CORBA NO_PERMISSION 0 No; nested exception is:
         org.omg.CORBA.NO_PERMISSION: ----------BEGIN server-side stack trace----------
    org.omg.CORBA.NO_PERMISSION:   vmcid: 0x0  minor code: 0  completed: No
         at com.sun.enterprise.iiop.security.SecServerRequestInterceptor.handle_null_service_context(SecServerRequestInterceptor.java:407)
         at com.sun.enterprise.iiop.security.SecServerRequestInterceptor.receive_request(SecServerRequestInterceptor.java:429)
         at com.sun.corba.ee.impl.interceptors.InterceptorInvoker.invokeServerInterceptorIntermediatePoint(InterceptorInvoker.java:627)
         at com.sun.corba.ee.impl.interceptors.PIHandlerImpl.invokeServerPIIntermediatePoint(PIHandlerImpl.java:530)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.getServantWithPI(CorbaServerRequestDispatcherImpl.java:406)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:224)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
         at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
         at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
    ----------END server-side stack trace----------  vmcid: 0x0  minor code: 0  completed: No
         at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:277)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:205)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
         at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
         at com.sun.ejb.codegen._GenericEJBHome_Generated_DynamicStub.create(com/sun/ejb/codegen/_GenericEJBHome_Generated_DynamicStub.java)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:372)
         ... 5 more
    Caused by: org.omg.CORBA.NO_PERMISSION: ----------BEGIN server-side stack trace----------
    org.omg.CORBA.NO_PERMISSION:   vmcid: 0x0  minor code: 0  completed: No
         at com.sun.enterprise.iiop.security.SecServerRequestInterceptor.handle_null_service_context(SecServerRequestInterceptor.java:407)
         at com.sun.enterprise.iiop.security.SecServerRequestInterceptor.receive_request(SecServerRequestInterceptor.java:429)
         at com.sun.corba.ee.impl.interceptors.InterceptorInvoker.invokeServerInterceptorIntermediatePoint(InterceptorInvoker.java:627)
         at com.sun.corba.ee.impl.interceptors.PIHandlerImpl.invokeServerPIIntermediatePoint(PIHandlerImpl.java:530)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.getServantWithPI(CorbaServerRequestDispatcherImpl.java:406)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:224)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
         at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
         at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
    ----------END server-side stack trace----------  vmcid: 0x0  minor code: 0  completed: No
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
         at com.sun.corba.ee.impl.protocol.giopmsgheaders.MessageBase.getSystemException(MessageBase.java:913)
         at com.sun.corba.ee.impl.protocol.giopmsgheaders.ReplyMessage_1_2.getSystemException(ReplyMessage_1_2.java:131)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.getSystemExceptionReply(CorbaMessageMediatorImpl.java:685)
         at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(CorbaClientRequestDispatcherImpl.java:472)
         at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(CorbaClientRequestDispatcherImpl.java:363)
         at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:219)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:192)
         ... 13 moreAny help is appreciated.
    Regards!
    Nithi.
    Edited by: EJB3 on Aug 17, 2008 8:17 PM

Maybe you are looking for

  • HP Officejet 4315 All-in-One

    I have an HP Officejet 4315 All-in-One that I bought several computers ago.  I now have 2 computes that have Windows 8.1 on them, and the installation disc is for Windows 2000 and Windows XP.  The installation disc says that my system doesn't have wh

  • Set up new iPhone 5 with iCloud restore, then iTunes created new library with only content already on phone. How do I find and sync everything in original library?

    My daughter got a new iPhone 5 and we set it up using the option to restore her iPhone 4 backup from iCloud. This worked great and everything on the old phone showed up on the new phone. Because we were traveling, we weren't able to sync the iPhone 5

  • Photoshop Album 3.0 SE

    I just got an iPod 60GB and am trying to sync my photos from my PC using iTunes 4.9 and PhotoShop Album 3.0 SE (i.e., the free version). According to Apple.com: "Note: While Photoshop Album allows you to sync only certain collections, Photoshop Album

  • Bulk Renaming Problem in Adobe Bridge

    Hi I have an inconvenient problem in bulk renaming files in Adobe Bridge CS3. An original file name for example looks like: DSC_5521 I wish to keep the "5521" part in my bulk renaming process so it may look for example like "Landscape5521" but loose

  • Problem with variable optimized away by compiler

    I'm trying to write a c++ program, but in this class method, one of the variables will not take an assignment. As I step through it in the debugger, it says that the variable i is being optimized away... Why is this happening and how can I stop it? H