A JRuby class manipulation tool built on top of Javassist. Currently in prototype state.
Java Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
demo
javalibs
javassist
javatest/com/quadcs/hacksaw/tests
lib
nbproject
src
test
.DS_Store
.gitignore
Hacksaw.jar
License.html
MANIFEST.MF
README
build.xml
hacksaw.gemspec
hacksaw.sh
javac.classes
javac.options
rakefile.osx
rakefile.win32
rgi.bat

README

Hello -

  This project is currently a prototype! I'm just trying to get my ideas together in one place.

But, the idea is to have something like this in JRuby:

modify :classes=>/com\.quadcs\.hacksaw\.demo\.DemoAccount/ do |c|
    c.add_field 'public int z = 0;'  

    c.modify :field=>"accountNumber" do |f|
      f.change_modifiers [:public]
    end
    
    c.modify :method=>"isValidAccount" do |m|  
      m.add_line_before 'if(accountNumber.equals("abcd")) { return true; }'
    end    
    
    c.add_method 'public String somethingNew(int dx) { return accountNumber + "." + z + "." + dx; }'    
end

# Append this to the JVM options when JRuby is started:
# -J-javaagent:/path/to/Hacksaw.jar

See the demo directory! 

Cheers!
Dave