• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java source code analyser

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to find classes which extends "Thread" or implements "Runnable" from java source code and then replace code of its instance which starts a new thread with another piece of code. Is there any existing tool completing this task?

Thanks.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use Eclipse for this. Select the class or interface and press Ctr+Shift+g. It will search and list the references.
 
puff li
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Namam,

Thanks. I think I didn't make myself clear. I wanna write a program to do this automatically. I have a bunch of source file to process.
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if I understand what you're asking, but dosen't every class that extends Thread or implements Runnable do exactly what you described? Look here. If I misunderstood you please refrase the question
 
puff li
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know how to start a thread. My problem is to replace normal way of starting a thread with the way of Javaflow. So I need to look at the source code and replace obj.start() with Continuation.startWith(obj). Since other classes can also have the start() method, I can't simply find start() in source code and replace it directly. I need to make sure the obj extends Thread. The situation is complicated because you can return a Thread object from a function (ie. a.returnThread().start()), then I have to make sure a.returnThread() returns an object of Thread.

Am I clear?
 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I don't know of any such tool. If you find it please report back, it seems like a powerfull thing ... if it exists
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The original answer of "use Eclipse" is not a bad idea, actually. You could write an Eclipse plug-in which leveraged the Java development tools in Eclipse -- it would work the same way that the various refactorings do. There are plenty of example open-source Eclipse plugins that implement various refactorings, so you can probably find something quite close to what you want and modify it.

Another alternative would be a bytecode-processing library like Javassist, which lets you read, write, and modify class files directly. You wouldn't have the modified source code then, of course.

 
Marshal
Posts: 79412
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked in the API documentation for Runnable or Thread? Doesn't it give a list of implementing classes and subclasses?
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic