river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Firmstone (JIRA)" <j...@apache.org>
Subject [jira] Commented: (RIVER-272) ClassDep.java relies on Sun specific Internal JDK API
Date Wed, 22 Apr 2009 05:55:47 GMT

    [ https://issues.apache.org/jira/browse/RIVER-272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12701395#action_12701395
] 

Peter Firmstone commented on RIVER-272:
---------------------------------------

Thanks Jonathan for merging the latest patch,

We've got some loose ends to tidy up, the ASM libraries aren't picked up when using classdep.jar
from the command line.

ClassDepLoader.java is where ClassDep is being called from, it's still looking for the sun
tools.jar library

It appears that ClassDepLoader is only used from the command line to find the sun tools.jar
library and add it to the URL loader classpath before calling the ClassDep reflectively.

I have been calling ClassDep's main method directly during my testing.

I don't think we need ClassDepLoader anymore and we need to link in the ASM libs into the
dependencies.

What do you think?

Cheers,

Peter.

Also line 2087 in build.xml refers to a class that no longer exists, I deleted it.

<target name="tools.jar" depends="river.jars">
        <property name="tools.deps" location="${build.deps.dir}/tools.deps" />

            <arg value="com.sun.jini.tool.ClassDep$$Env"/>
            <arg value="com.sun.jini.tool.ClassDepLoader"/>


bash-3.00$ /usr/jdk/j2sdk1.4.2_12/jre/bin/java -jar ./lib/classdep.jar -cp tools/asm-3.1.jar:tools/asm-commons-3.1.jar:../../TimeAndMoney/build/timeandmoney-v0_5_1.jar
-in com.domainlanguage -edges com.domainlanguage.money.Money
failure loading ClassDep
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at com.sun.jini.tool.ClassDepLoader.main(ClassDepLoader.java:87)
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
        at com.sun.jini.tool.classdepend.ClassDepend.getDependencyRelationshipMap(ClassDepend.java:251)
        at com.sun.jini.tool.ClassDep.compute(ClassDep.java:885)
        at com.sun.jini.tool.ClassDep.main(ClassDep.java:1329)
        ... 5 more


ClassDepLoader.java source code:

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.sun.jini.tool;

import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.text.MessageFormat;

import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.StringTokenizer;

/**
 * Class to provide the <code>main</code> method referenced by the
 * <code>Main-Class</code> entry in the manifest of the <code>classdep</code>
 * JAR file. <code>ClassDep</code> relies on <code>sun.tools</code>
 * classes which may not be available in the boot or extension classloader;
 * this class provides support for finding the JDK <code>tools.jar</code> file
 * at runtime and running <code>ClassDep</code> from a classloader which
 * includes that file.
 */
class ClassDepLoader {

    /**
     * Entry point for an executable JAR file for <code>ClassDep</code>.  Search
     * for <code>tools.jar</code> in <code>$java.home/../lib/</code>.
If the
     * file is found, construct a classloader using <code>URL</code>s generated
     * from the union of the value of <code>java.class.path</code> and the path
     * to the <code>tools.jar</code> file with the extension classloader as
     * parent. Then reflectively call the <code>main</code> method of the
     * <code>ClassDep</code> class obtained from that loader.
     * <p>
     * If no <code>tool.jar</code> file is found, <code>ClassDep.main</code>
     * is called directly.
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    File javaHome = new File(System.getProperty("java.home"));
    String jarPath = "lib" + File.separator + "tools.jar";
    File toolsJar = new File(javaHome.getParent(), jarPath);
    if (!toolsJar.exists()) {
        try {
        Class.forName("sun.tools.java.Constants");
        } catch (ClassNotFoundException e) {
        print("classdep.notools", toolsJar.toString());
        return;
        }
        ClassDep.main(args);
    } else {
        try {
        String classpath = System.getProperty("java.class.path");
        classpath += File.pathSeparator + toolsJar;
        StringTokenizer st = new StringTokenizer(classpath,
                             File.pathSeparator);
        URL[] urls = new URL[st.countTokens()];
        for (int i=0; st.hasMoreTokens(); i++) {
            urls[i] = new File(st.nextToken()).toURI().toURL();
        }
                ClassLoader cl = ClassLoader.getSystemClassLoader();
        if (cl != null) {
            cl = cl.getParent();
        }
        ClassLoader loader = new URLClassLoader(urls, cl);
        Class classdepClass =
            Class.forName("com.sun.jini.tool.ClassDep", true, loader);
        Method mainMethod =
            classdepClass.getMethod("main",
                        new Class[] {String[].class});
        mainMethod.invoke(null, new Object[]{args});
        } catch (Throwable e) {
        print("classdep.loadfailed", null);
        e.printStackTrace();
        }
    }
    }
    
    /** print a localized message */
    private static void print(String key, String v1) {
    Object[] vals = (v1 == null) ? null : new Object[]{v1};
    try {
        String name = "com.sun.jini.tool.resources.classdep";
        ResourceBundle resources = ResourceBundle.getBundle(name);
        String fmt = resources.getString(key);
        System.err.println(MessageFormat.format(fmt, vals));
    } catch (MissingResourceException e) {
        e.printStackTrace();
    }
    }
}


> ClassDep.java relies on Sun specific Internal JDK API 
> ------------------------------------------------------
>
>                 Key: RIVER-272
>                 URL: https://issues.apache.org/jira/browse/RIVER-272
>             Project: River
>          Issue Type: Improvement
>          Components: com_sun_jini_tool
>    Affects Versions: jtsk_2.1
>         Environment: Windows XP, JDK 1.4 - JDK 1.6, Eclipse 3.3 IDE
>            Reporter: Hakan Kocakulak
>         Attachments: ClassDep-a4.patch, ClassDep-a5.patch, ClassDep-a6.patch, classdepend.zip,
classdepend_backport.tgz, ClassDepReplacement.tgz, ClassDepReplacement_alpha-2.tgz, ClassDepReplacement_alpha-3.tgz,
ClassDepReplacement_alpha-4.tgz
>
>
> ClassDep.java relies on Sun specific Internal JDK API 
> import sun.tools.java.BinaryClass;
> > import sun.tools.java.ClassDeclaration; import 
> > sun.tools.java.ClassFile; import sun.tools.java.ClassNotFound; import 
> > sun.tools.java.ClassPath; import sun.tools.java.Constants; import 
> > sun.tools.java.Environment; import sun.tools.java.Identifier; import 
> > sun.tools.java.MemberDefinition; import sun.tools.java.Package; import 
> > sun.tools.java.Type;
> while building from eclipse IDE, IDE do not add these Classes to classpath and can not
build project.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message