debug or utility capabilty to see jar methods, packages, or classes.

6 views
Skip to first unread message

Poarman

unread,
Mar 27, 2008, 8:02:57 PM3/27/08
to Sleep Developers
Hi Raph,

I remember you showing me how to dump methods from a class but can't
find where i wrote it down. what I want to do is create a small
utility library that will allow me to do the following:

- return the Java type of a sleep variable
- return packages in a jar file
- return classes in a jar file
- return methods in a jar file (or in a class in a jar)

Have a GREAT day!)

pourman

Raphael Mudge

unread,
Mar 28, 2008, 11:43:33 AM3/28/08
to Sleep Developers
> - return the Java type of a sleep variable

$object = [new LinkedList];
println([$object getClass]);

> - return packages in a jar file
> - return classes in a jar file

This will require a little more work to parse out the jar file and get
packages and classes, however the core is here. This snippet shows
how to parse the entries out of a jar file.

import java.util.jar.*;
import java.io.*;

$jarfile = [new JarFile: [new File: "sleep.jar"]];

$enum = [$jarfile entries];
while ([$enum hasMoreElements])
{
$entry = [$enum nextElement];
$name = [$entry getName];

# $name is the name of the file in the .jar
# $entry isa java.util.zip.ZipEntry
}

> - return methods in a jar file (or in a class in a jar)

$object = [new LinkedList];
printAll([[$object getClass] getMethods]);
Reply all
Reply to author
Forward
0 new messages