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*.c lass$*|*grep*$1 )
********for*c*i n*$h;do
*************ec ho*$c;
********done
****done*
}
function jif() {
****for*j*in*${ CLASSPATH//:/'*'};*do
********h="";
********h=$(jar *-tf*$j*|*grep*.c lass$*|*grep*$1 )
********for*c*i n*$h;do
************tes t*-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/SystemIDResolve r.class
org/apache/xpath/functions/FuncSystemPrope rty.class
org/apache/xmlrpc/SystemHandler.c lass
org/apache/xindice/core/MetaSystemColle ction.class
org/apache/xindice/core/SystemCollectio n.class
If I want to see the interfaces for each of these, I enter:
org/apache/xml/utils/SystemIDResolve r.class
Compiled from "SystemIDResolv er.java"
public class org.apache.xml. utils.SystemIDR esolver extends java.lang.Objec t{
****public*org. apache.xml.util s.SystemIDResol ver();
****public*stat ic*java.lang.St ring*getAbsolut eURI(java.lang. String);
*******throws*j avax/xml/transform/TransformerExce ption
****public*stat ic*java.lang.St ring
getAbsoluteURIF romRelative(jav a.lang.String);
****public*stat ic*java.lang.St ring
getAbsoluteURI( java.lang.Strin g,java.lang.Str ing);
*******throws*j avax/xml/transform/TransformerExce ption
}
org/apache/xpath/functions/FuncSystemPrope rty.class
Compiled from "FuncSystemProp erty.java"
//...
}
org/apache/xmlrpc/SystemHandler.c lass
Compiled from "SystemHandler. java"
public class org.apache.xmlr pc.SystemHandle r extends java.lang.Objec t
implements org.apache.xmlr pc.ContextXmlR
//..
execute(java.la ng.String,java. util.Vector,org .apache.xmlrpc. XmlRpcContext);
*******throws*j ava/lang/Exception
}
org/apache/xindice/core/MetaSystemColle ction.class
Compiled from "MetaSystemColl ection.java"
public final class org.apache.xind ice.core.MetaSy stemCollection 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