Corrections to Chapter 19 of Java Secrets, Mixed Language Programming with Native Methods

p. 637: At the top of the page, change "to br sure" to "to be sure".

p. 638: In the secand paragraph, change "inside a C native metho;" to "inside a C native method".

p. 640: The Java program referred to incorrectly as Listing 19-8 is missing. Here it is

package numbers;

public class RevisedSums {

  static {
   System.loadLibrary("numbers");
  }

  public static void main(String[] args) {

    Sums s = new Sums();
    int result = s.firstNonSquareSum();
    System.out.println(result + " is not the sum of three squares.");

  }

  public native int firstNonTripleSum(int power);

}
p. 651: Change

LongVector = (*jne)->NewObject(jne, LongID, "<init>", size);

to

LongVector = (*jne)->NewObject(jne, LongID, VectorConstructorID, size);

p. 654: The signature for NewStringUTF has two arguments, not three. You do not need to pass the string length to the function. Its signature should read:

jstring NewStringUTF(JNIEnv *jne, const char *bytes);

The foillowing code fragment should be:

jstring jhello;
char* chello = "Hello";
hello = (*jne->) NewStringUTF(jne, chello);

[ Java Secrets Corrections | Java Secrets Home Page | Table of Contents | Examples | About the CD | Order ]

Copyright 1998, 2002 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified December 28, 2002