Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0C57A17382 for ; Wed, 24 Jun 2015 10:44:59 +0000 (UTC) Received: (qmail 51354 invoked by uid 500); 24 Jun 2015 10:44:57 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 51228 invoked by uid 500); 24 Jun 2015 10:44:57 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 51217 invoked by uid 99); 24 Jun 2015 10:44:57 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jun 2015 10:44:57 +0000 Received: from mail-ig0-f176.google.com (mail-ig0-f176.google.com [209.85.213.176]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 0BAF71A04A8 for ; Wed, 24 Jun 2015 10:44:56 +0000 (UTC) Received: by igbqq3 with SMTP id qq3so110794146igb.0 for ; Wed, 24 Jun 2015 03:44:56 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.107.163.146 with SMTP id m140mr52438145ioe.85.1435142696365; Wed, 24 Jun 2015 03:44:56 -0700 (PDT) Received: by 10.79.22.134 with HTTP; Wed, 24 Jun 2015 03:44:56 -0700 (PDT) In-Reply-To: References: Date: Wed, 24 Jun 2015 12:44:56 +0200 Message-ID: Subject: Re: is BCEL the tool for me? From: Benedikt Ritter To: Commons Users List Content-Type: multipart/alternative; boundary=001a113bb0d89e78680519413205 --001a113bb0d89e78680519413205 Content-Type: text/plain; charset=UTF-8 Hello Li Li, 2015-06-24 11:44 GMT+02:00 Li Li : > I have to use another package name other than the original one because > the original package is loaded and not controlled by my code. > I don't think you should mess around with the byte code in this situation. What if other code also uses the shared library and it depends on it's current behavior? You could introduce unforeseeable side effects. Doesn't the library you're using provide extension points you can use to add the desired functionality in a save way? Benedikt > > > On Wed, Jun 24, 2015 at 5:37 PM, Benedikt Ritter > wrote: > > Hello Li Li > > > > 2015-06-24 11:21 GMT+02:00 Li Li : > > > >> Hi all, > >> I have a jar file and without the source code, I want to replace > >> a package and all classes of this package with my own. > >> e.g. There is a package > >> com.abc.tool > >> com.abc.tool.A.class > >> com.abc.tool.B.class > >> The com.abc.tool.A.class and com.abc.tool.B.class are used in many > >> other classes. > >> I want to use my own implementation, So I can create my > >> package(com.def.tool) and my A.java B.java which has exactly the same > >> method as com.abc.tool.A.class and com.abc.tool.B.class > >> com.def.tool > >> com.def.tool.A.class > >> com.def.tool.B.class > >> But other classes in this jar still use com.abc.tool.A.class and > >> com.abc.tool.B.class. I want to use a byte code library to modify the > >> jar so it can run and use my implementation. > >> Is BCEL suitable for this? Thank you > >> > > > > This sounds like a pretty complicated solution to your problem. Why don't > > you just replace the class files in the jar at build time? > > > > Regards, > > Benedikt > > > > > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > >> For additional commands, e-mail: user-help@commons.apache.org > >> > >> > > > > > > -- > > http://people.apache.org/~britter/ > > http://www.systemoutprintln.de/ > > http://twitter.com/BenediktRitter > > http://github.com/britter > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > > -- http://people.apache.org/~britter/ http://www.systemoutprintln.de/ http://twitter.com/BenediktRitter http://github.com/britter --001a113bb0d89e78680519413205--