JDK-4368114 : RFE: javah should provide skeletal implementation
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javah
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: solaris_9,windows_2000
  • CPU: x86,sparc
  • Submitted: 2000-09-03
  • Updated: 2018-01-09
  • Resolved: 2018-01-09
Related Reports
Duplicate :  
Description
Name: krC82822			Date: 09/03/2000


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

The javah tool has a -stubs option, but that no longer works in JDK 1.3 and
should just be removed.  Aside from that, my main issue is that I am generating
over 600 functions via the javah tool.  I have to cut-and-paste the .H file
declarations into a .CPP file and add names for all the parameters, and add
extern "C" to EVERY function.  This is very annoying and time consuming, and
every time I re-generate the headers, it all has to be done over again.  I know
the information for generating source files with named parameters has to be
easily accessible from the .java source file, and that's why I am perplexed
that it hasn't be done.  PLEASE add a new option to this tool to generate a
source file with a fully formed prototype, and if possible, include a return
  statement in the function where appropriate.  As an example, here is what I
would like to see...

-----
.JAVA
-----

public MyClass
{
    public int value;
} 

public class Texture
{
   public static native boolean foo1(MyClass a, int i);
   static {
      System.LoadLibrary("Texture");
   }
}

-------------
.H from JAVAH
-------------

* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Texture */

#ifndef _Included_Texture
#define _Included_Texture
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     Texture
 * Method:    foo1
 * Signature: ()LTexture;
 */
JNIEXPORT boolean JNICALL Java_Texture_foo1
  (JNIEnv *, jclass, jobject, jint);

#ifdef __cplusplus
}
#endif
#endif

----------------
.C or .CPP File (What I'd like to see...)
----------------

#include <jni.h>
#include "Texture.h"
/*
 * Class:     Texture
 * Method:    foo1
 * Signature: ()LTexture;
 */
extern "C" JNIEXPORT boolean JNICALL Java_Texture_foo1
  (JNIEnv *env, jclass cl_Texture, jobject a, jint i) // <--- notice naming
{
   jboolean jbResult = false;

   // TODO : INSERT YOUR CODE HERE

   return jbResult;
}
(Review ID: 108023) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
08-09-2004

WORK AROUND Name: krC82822 Date: 09/03/2000 I have to do this entire process manually. ======================================================================
08-09-2004

PUBLIC COMMENTS ..
08-09-2004

EVALUATION Hey, if -stubs doesn't work then the tool is broken. Reclassifying as a bug. Changed synopsis from Have javah also generate a .C/.CPP file alongside the .h file to javah -stubs doesn't work at all neal.gafter@Eng 2000-12-13 I seem to have missed the main point of this request in the previous evaluation. I'll try to do this in the Tiger timeframe. ###@###.### 2002-02-06 Too late for Tiger, will be reconsidered for next feature J2SE release. ###@###.### 2003-11-05
06-02-2002