javah
Jonathan Gibbons
jonathan.gibbons at oracle.com
Mon Mar 12 18:17:05 PDT 2012
Greg,
Same results.
-- Jon
On 03/12/2012 06:13 PM, Greg Brown wrote:
> Hi Jon,
> Thanks for looking into this. Could you possibly try running your test with Inner as a nested (static) class rather than an inner class? I wonder if that might have something to do with the difference in behavior.
> Greg
>
> On Mar 12, 2012, at 7:30 PM, Jonathan Gibbons wrote:
>
>> On 03/12/2012 12:30 PM, Greg Brown wrote:
>>>>> Has the behavior of javah changed in Java 7? I'm using the<javah> task in Ant to generate some JNI headers. When I run my Ant script under Java 6, I only get headers for classes I explicitly specify. Under Java 7, I get headers for all of my specified classes as well as any nested classes defined by those classes, even though the nested classes themselves don't specify any native methods.
>>>>>
>>>>> I'm not sure if Ant or javah is responsible for the change, but if it is javah - is this intentional, or is it a bug?
>>>>>
>>>>> Thanks,
>>>>> Greg
>>>>>
>>>> javah was rewritten in JDK 7, but the intent was the headers generated should be the same as for earlier versions of javah.
>>> So, to confirm - the fact that these headers were are generated in Java 6 but are generated in Java 7 is likely a bug?
>>>
>>>
>>>
>> Greg,
>>
>> I see the same behavior on JDK 5, 6, 7, 8.
>>
>> Here's my test program:
>>> package p;
>>>
>>> class C {
>>> native void m();
>>>
>>> class Inner {
>>> void m2() { }
>>> }
>>> }
>> Here's my test script:
>>> #!/bin/sh
>>>
>>> rm -rf play/classes play/jdk*
>>>
>>> mkdir play/classes
>>> /opt/jdk/1.5.0/bin/javac -d play/classes $(find play/src -name \*.java)
>>>
>>> for i in 5 6 7 8 ; do
>>> mkdir play/jdk$i
>>> /opt/jdk/1.$i.0/bin/javah -classpath play/classes -d play/jdk$i p.C
>>> done
>>>
>>> find play/jdk*
>> And here's the output:
>>> $ sh -x play/test.sh
>>> + rm -rf play/classes play/jdk5 play/jdk6 play/jdk7 play/jdk8
>>> + mkdir play/classes
>>> + find play/src -name *.java
>>> + /opt/jdk/1.5.0/bin/javac -d play/classes play/src/p/C.java
>>> + mkdir play/jdk5
>>> + /opt/jdk/1.5.0/bin/javah -classpath play/classes -d play/jdk5 p.C
>>> + mkdir play/jdk6
>>> + /opt/jdk/1.6.0/bin/javah -classpath play/classes -d play/jdk6 p.C
>>> + mkdir play/jdk7
>>> + /opt/jdk/1.7.0/bin/javah -classpath play/classes -d play/jdk7 p.C
>>> + mkdir play/jdk8
>>> + /opt/jdk/1.8.0/bin/javah -classpath play/classes -d play/jdk8 p.C
>>> + find play/jdk5 play/jdk6 play/jdk7 play/jdk8
>>> play/jdk5
>>> play/jdk5/p_C_Inner.h
>>> play/jdk5/p_C.h
>>> play/jdk6
>>> play/jdk6/p_C_Inner.h
>>> play/jdk6/p_C.h
>>> play/jdk7
>>> play/jdk7/p_C_Inner.h
>>> play/jdk7/p_C.h
>>> play/jdk8
>>> play/jdk8/p_C_Inner.h
>>> play/jdk8/p_C.h
>> -- Jon
>>
More information about the macosx-port-dev
mailing list