This was written for the gnu.g++.help list. It rather clearly spells out the
most important feature of Java that I believe C++ lacks. I really don't
believe the C++ Standard sepcifies enough for a generic mechanism to
accomplish the comperable tasks demonstrated for Java below. I've already
proposed on comp.std.c++ that the next version of the standard specify a
similar functionality for a C++ implementation.
I know it can be unpopular to compare Java to C++, but there are certain
features of Java which C++ lacks, and which give the programmer significant
leverage to exploit available libraries.
I wrote the following bash for the sake of writing this [gnu.g++.help]
response:
*#!/bin/bash
function jarlist() {
****for*j*in*${CLASSPATH//:/'*'};*do*
********echo*$j;
****done*
}
function classlist() {
****for*j*in*${CLASSPATH//:/'*'};*do
********jar*-tf*$j;
****done*
}
function jpgrep() {
****for*j*in*${CLASSPATH//:/'*'};*do
********h="";
********h=$(jar*-tf*$j*|*grep*.class$*|*grep*$1)
********for*c*in*$h;do
*************echo*$c;
********done
****done*
}
function jif() {
****for*j*in*${CLASSPATH//:/'*'};*do
********h="";
********h=$(jar*-tf*$j*|*grep*.class$*|*grep*$1)
********for*c*in*$h;do
************test*-n*"$c"*&&*echo*$c*&&*javap*${c%%.class}
********done
****done*
}
##################### EOF ###################################
If there is a Java class I wish to use in my code, I can put the code listed
above in a file called ~/bin/jq. Source it:
Fri Jun 04 11:45:51:> . jq
If I know the class contains the substring 'System' I type:
Fri Jun 04 11:45:51:> jpgrep System
org/apache/xml/utils/SystemIDResolver.class
org/apache/xpath/functions/FuncSystemProperty.class
org/apache/xmlrpc/SystemHandler.class
org/apache/xindice/core/MetaSystemCollection.class
org/apache/xindice/core/SystemCollection.class
If I want to see the interfaces for each of these, I enter:
org/apache/xml/utils/SystemIDResolver.class
Compiled from "SystemIDResolver.java"
public class org.apache.xml.utils.SystemIDResolver extends java.lang.Object{
****public*org.apache.xml.utils.SystemIDResolver() ;
****public*static*java.lang.String*getAbsoluteURI( java.lang.String);
*******throws*javax/xml/transform/TransformerException
****public*static*java.lang.String
getAbsoluteURIFromRelative(java.lang.String);
****public*static*java.lang.String
getAbsoluteURI(java.lang.String,java.lang.String);
*******throws*javax/xml/transform/TransformerException
}
org/apache/xpath/functions/FuncSystemProperty.class
Compiled from "FuncSystemProperty.java"
//...
}
org/apache/xmlrpc/SystemHandler.class
Compiled from "SystemHandler.java"
public class org.apache.xmlrpc.SystemHandler extends java.lang.Object
implements org.apache.xmlrpc.ContextXmlR
//..
execute(java.lang.String,java.util.Vector,org.apac he.xmlrpc.XmlRpcContext);
*******throws*java/lang/Exception
}
org/apache/xindice/core/MetaSystemCollection.class
Compiled from "MetaSystemCollection.java"
public final class org.apache.xindice.core.MetaSystemCollection extends
//...
Those results contain everything I need in order to have the class imported
into my current file and to get a pop-up menu of accessible method
invocations and fields, including a parameterlist.
--
STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org