Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #34676

Re: How to write a URLClassLoader in Java such that it can execute a block of code prior to loading certain classes?

Newsgroups comp.lang.java.programmer
Date 2016-06-20 11:04 -0700
References <ee393144-64b8-4f19-8597-e139f401db85@googlegroups.com>
Message-ID <cdb2d366-a6a6-446b-abf2-db98908bafe5@googlegroups.com> (permalink)
Subject Re: How to write a URLClassLoader in Java such that it can execute a block of code prior to loading certain classes?
From Lew <lewbloch@gmail.com>

Show all headers | View raw


On Monday, June 20, 2016 at 12:42:25 AM UTC-7, kant kodali wrote:
> public class MyClassLoader extends URLClassLoader {
>     
>         public MyClassLoader() throws Exception{
>              super(new URL[]{new URL("file:///home/ubuntu/java/hello.jar")});
>         }
>     
>         @Override
>         public Class loadClass(String name) throws ClassNotFoundException {
>             if (name.equals("hello.example.org.Foo") || name.equals("hello.example.org.Bar")) 
>             {
>                 System.out.println("Foo or Bar is loaded");
>             }

'System.out' is not the channel for log messages.

-- 
Lew

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to write a URLClassLoader in Java such that it can execute a block of code prior to loading certain classes? kant kodali <kanth909@gmail.com> - 2016-06-20 00:42 -0700
  Re: How to write a URLClassLoader in Java such that it can execute a block of code prior to loading certain classes? Lew <lewbloch@gmail.com> - 2016-06-20 11:04 -0700
  Re: How to write a URLClassLoader in Java such that it can execute a block of code prior to loading certain classes? Arne Vajhøj <arne@vajhoej.dk> - 2016-07-10 20:12 -0400

csiph-web