Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

jni

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I always got the following error message. Does anyone knows the causes of such error messages? Thanks
p28.c: In function `Java_p28_setAPrivate':
p28.c:6: request for member `GetObjectClass' in something not a structure or union
p28.c:7: request for member `GetFieldID' in something not a structure or union
p28.c:8: request for member `SetIntField' in something not a structure or union
Here is my source code
---------------------------------------------------------------
#include "p28.h"
#include <jni.h>
JNIEXPORT void JNICALL Java_p28_setAPrivate(JNIEnv *env, jobject thisObj, jint val)
{
jclass clazz = env->GetObjectClass(thisObj);
jfieldID fid = env->GetFieldID (clazz, "aPrivate","I");
env->SetIntField(thisObj,fid,val);
}
---------------------------------------------------------------
public class p28
{
private int aPrivate=0;
protected int aProtected=0;
public int aPublic=0;
private static int aStaticPrivate=0;
protected static int aStaticProtected=0;
public static int aStaticPublic =0;
public void printAPrivae()
{
System.err.println("A Private = " + aPrivate);
}
public void printAProtected()
{
System.err.println("A Protected = "+ aProtected);
}
public void printAStaticPrivate()
{
System.err.println("A StaticPrivate = "+ aStaticPrivate);
}
public void printAStaticProtected()
{
System.err.println("A StaticProtected = "+aStaticProtected);
}
public native void setAPrivate(int val);
public native void setAStaticPrivate(int val);
}
---------------------------------------------------------------
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, assuming you copied/pasted your source code exactly you have no header file jni.h that describes the missing strucutres, try including it!
Rgds, A
 
Sita Yo
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in fact I have included the jni.h, perhaps there is some error due to cut and paste. Still the same errors appear
Regards
 
Men call me Jim. Women look past me to this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic