Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6204834

REGRESSION: jawt drawing surface locking problem

XMLWordPrintable

    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Linux pawelp 2.4.25-1-386 #2 Wed Apr 14 19:38:08 EST 2004 i686

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      P4 2.7
      512 MB Ram
      32 MB Video Card

      A DESCRIPTION OF THE PROBLEM :
      I implement the MyCanvas example of the Jawt native interface.

      This allows me to draw in c++ directly on the java canvas.

      When I run the code on java 1.5 the "lock = ds->Lock(ds);"
      does not lock the draw surface and throughs an "JAWT_LOCK_ERROR"
      Exception.

      The code does run on java 1.4.2 with out an exception.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile the c++ code to generate a .o file.
      2. Link library to make a libtest.so.
      3. Compile Java Code.
      4. set LD_LIBRARY_PATH to include libtest.so.
      5. Run java Code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No errors are shown.
      ACTUAL -
      Exception is thrown that states "Error locking surface".

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      "Error locking surface".

      The java Error is "JAWT_LOCK_ERROR".

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      MyCanvas.c

      ---------------------------------

      #include <jawt_md.h>
      #include "MyCanvas.h"


      JNIEXPORT void JNICALL Java_com_ads_mapping_MyCanvas_paint
      (JNIEnv* env, jobject canvas, jobject graphics)
      {
          JAWT awt;
          JAWT_DrawingSurface* ds;
          JAWT_DrawingSurfaceInfo* dsi;
          JAWT_X11DrawingSurfaceInfo* dsi_x11;
          jboolean result;
          jint lock;
          GC gc;

          /* Get the AWT */
          awt.version = JAWT_VERSION_1_4;
          if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
              printf("AWT Not found\n");
              return;
          }

          /* Get the drawing surface */
          ds = awt.GetDrawingSurface(env, canvas);
          if (ds == NULL) {
              printf("NULL drawing surface\n");
              return;
          }

          /* Lock the drawing surface */
          lock = ds->Lock(ds);
          if((lock & JAWT_LOCK_ERROR) != 0) {
              printf("Error locking surface\n");
      awt.FreeDrawingSurface(ds);
              return;
          }

          /* Get the drawing surface info */
          dsi = ds->GetDrawingSurfaceInfo(ds);
          if (dsi == NULL) {
              printf("Error getting surface info\n");
              ds->Unlock(ds);
              awt.FreeDrawingSurface(ds);
              return;
          }

          /* Get the platform-specific drawing info */
          dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;


          /* Now paint */


          /* End paint */

          /* Free the drawing surface info */
          ds->FreeDrawingSurfaceInfo(dsi);

          /* Unlock the drawing surface */
          ds->Unlock(ds);

          /* Free the drawing surface */
          awt.FreeDrawingSurface(ds);

      }

      ------------------------------------

      MyCanvas.h

      ------------------------------------

      #include <jni.h>
      #include <map>
      /* Header for class MyCanvas */

      #ifndef _Included_MyCanvas
      #define _Included_MyCanvas
      #ifdef __cplusplus
      extern "C" {
      #endif

      /*
       * Class: MyCanvas
       * Method: paint
       * Signature: (Ljava/awt/Graphics;)V
       */

      JNIEXPORT void JNICALL Java_com_ads_mapping_MyCanvas_paint
      (JNIEnv* env, jobject canvas, jobject graphics);

      #ifdef __cplusplus
      }
      #endif
      #endif

      ------------------------------------

      MyCanvas.java

      import java.awt.*;
      import java.awt.event.*;

      public class MyCanvas extends Canvas {
          static {
              System.loadLibrary("test");
          }
          public native void paint(Graphics g);

          public static void main(String[] args) {
              Frame f = new Frame();
              f.setBounds(0, 0, 500, 110);
              f.add( new MyCanvas() );
              f.addWindowListener( new WindowAdapter() {
                  public void windowClosing(WindowEvent ev) {
                      System.exit(0);
                  }
              } );
              f.show();
          }
      }
      ---------- END SOURCE ----------

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.
      ###@###.### 2004-12-07 00:53:24 GMT

            denis Denis Fokin (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: