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

JDK should be updated to use standard iostream, restriction should be documented

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3_01
    • hotspot
    • sparc
    • solaris_7

      After invoking a JNI method that uses outputs to the C++ cerr, the compiler errors appears in using - #include <iostream> in Hello.cc file.

      "Hello.cc", line 2: Error: Could not open include file <iostream>.
      "Hello.cc", line 7: Error: Could not open include file "Hello.h".
      "Hello.cc", line 11: Error: cerr is not defined.
      "Hello.cc", line 11: Error: endl is not defined.
      4 Error(s) detected.


      Here's a sample Java program demonstrating the problem:

          public class Hello {

      public native void doIt();

      static public void main( String [] args ) {
      System.loadLibrary( "Hello" );
      Hello h = new Hello();
      h.doIt();
      System.out.println( "Did it" );
      }
          }

      And the native code:

          #include <iostream>
          using namespace std;

          #include <jni.h>

          #include "Hello.h"

          JNIEXPORT void JNICALL Java_Hello_doIt( JNIEnv *jenv, jobject jpeer )
          {
      cerr << "Hello JNI!" << endl;
          }

      It is compiled with:

          % javac Hello.java
          % javah -jni Hello
          % C -mt -G -o libHello.so -I/usr/j2se/include -I/usr/j2se/include/solaris
      Hello.cc -library=iostream,no%Cstd


      and run with:

         % setenv CLASSPATH .:$CLASSPATH
         %java Hello


      The C++ compilers used to test are:

          CC: Sun WorkShop 6 2000/08/30 C++ 5.1 Patch 109490-01
          CC: Sun WorkShop 6 update 1 C++ 5.2 2000/09/11
        
      and both exhibit the problem.

      workaround: #include <iostream.h>


            kbr Kenneth Russell (Inactive)
            yujchen Yujing Chen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: