Results 1 to 3 of 3
  1. #1
    andrew222 is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default Java reflection: find serializable classes in package

    In Java, is there a way to find all classes within a package that are serializable and then add the Class object for these classes to a collection?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,529
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by andrew222 View Post
    In Java, is there a way to find all classes within a package that are serializable and then add the Class object for these classes to a collection?
    It can't be done because you don't know where your classpath points to and where it'll point to in the future.

    kind regards,

    Jos

  3. #3
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Not via the API, as far as I'm aware. I think you would have to directly process byte code. I went searching through the ClassLoader API and the Package API and was surprised to find that there does not seem to be any way to get a collection of classes.

Similar Threads

  1. Replies: 6
    Last Post: 01-30-2009, 10:24 AM
  2. get classes of a certain package
    By ashraf shaban in forum New To Java
    Replies: 4
    Last Post: 07-08-2008, 07:20 PM
  3. Replies: 2
    Last Post: 07-04-2008, 12:33 PM
  4. Replies: 1
    Last Post: 12-18-2007, 10:41 AM
  5. couldn't find the package java.lang
    By katie in forum New To Java
    Replies: 2
    Last Post: 08-04-2007, 05:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •