Thread: K5 JBPatch
View Single Post
Old 10-12-2012, 08:08 AM   #824
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,903
Karma: 6677559
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Quote:
Originally Posted by ixtab View Post
The easiest solution may be to simply overwrite the main class (com.lab126.linux.arm.LuigiServiceProvider) in start.sh with, say, com.mobileread.ixtab.jbpatch.bootstrap.K3Startup (or so). This class would do all the required wiring, and then call the LuigiServiceProvider main() method.

Should be about 10 lines of code...
Here's some code:

Code:
package com.mobileread.ixtab.jbpatch.bootstrap;

import java.lang.reflect.Method;

public class K3Startup {

	public static void main(String[] args) {
		try {
			// set up JBPatch classloader
			PatchingClassLoader.inject();
			new Stage2().run();
			
			// invoke "real" startup class
			Class startup = Class.forName("com.lab126.linux.arm.LuigiServiceProvider");
			Method main = startup.getMethod("main", new Class[] {String[].class});
			main.invoke(null, new Object[] {args});
		} catch (Throwable t) {
			t.printStackTrace();
		}
		
	}

}
Give this a try, it might even work

Of course, this requires the framework startup script to be changed to use com.mobileread.ixtab.jbpatch.bootstrap.K3Startup as the main class, and the jbpatch jar to be in the classpath (I suggest /opt/amazon/ebook/lib/jbpatch.jar)

If the framework starts up normally, you can then check /tmp/jbpatch.log to see if JBPatch is working correctly.

Last edited by ixtab; 10-23-2012 at 03:16 PM.
ixtab is offline   Reply With Quote