ListArgs Assignment

Due: Midnight March 12, 2003

Late Points: You will lose 1% of the grade for this assignment for each day it is late.


Deliverables

Send email to vickery@dijkstra with a tar file of your empty project directory attached. Be sure to include "CS-701 Assignment 3" in the subject line of your email, and put your name and ID number in the body of your message.

Typing "make" in the project directory must create a shared library named libla.so and install it in the directory $HOME/lib. It must also create a Java class file named ListArgs.class in the project directory. There must be no error or warning messages when this make commmand is run. Your Makefile must also provide targets named depend and clean which operate in the usual way, also with no warning or error messges. The Makefile and the Java and C++ source files must be coded according to the Coding Guidelines for the course, including proper use of RCS keywords. The only header file (other than system-supplied ones) is to be ListArgs.h, which is to be built by javah as part of the make process. Make clean should remove all javah-generated header files, which should not be checked into RCS.

Functionality

After running make, the command "listargs ..." must print all the command line arguments entered, one per line, and exit. When your program is run, listargs will be an alias for "java ListArgs," and the user's LD_LIBRARY_PATH will include $HOME/lib. I will set up this alias and environment variable on my system before testing your code; you may do the same on your own system outside of the project, such as in your .bashrc file.

Description

This is an exercise in Makefile design and RCS management. It also gives you practice using JNI. The ListArgs class is to call a native C++ method named doMain(), defined in a file named ListArgs.cc. The Java code is to pass a reference to the args variable, received by its main() method, to doMain(). The doMain() method receives args as a javaobjectArray. It uses GetArrayLength() to find out how long the array is, then uses GetObjectArrayElement() to extract successive jstring objects from the array, and prints each jstring after converting it to a C string using GetStringUTFChars(). Be sure to release each string after printing it.