[rules-users] Get compiled Java Code of Rules

Markus Helbig mhelbig81 at googlemail.com
Wed Dec 5 02:23:23 EST 2007


Here's the way it works for those who are interested


-- create a Packagebuilder and build package

JavaDialect jd = (JavaDialect) builder.getDialectRegistry().getDialect("java");

Field field = jd.getClass().getDeclaredField("src");
field.setAccessible(true);

MemoryResourceReader src = (MemoryResourceReader) field.get(jd);

String[] list = src.list();
    			
for (int z = 0; z < list.length; z++)
{
       String name = (String) list[z];
       byte[] bytes = src.getBytes( name );

       System.out.println(new String(bytes));
}

-----

thx for the help ...

2007/11/29, Markus Helbig <mhelbig81 at googlemail.com>:
> hmm ...
>
> PackageCompilatData data = pkg.getPackageCompilationData(); // gets the
> String[] list = data.list() // returns the list of files
> Byte[] bytes = data.read( list[0] ) // get the bytecode for
> new String(bytes);
>
> just gives me the bytecode ... but i will try with the PackageBuilder ...
>
> Cheers
>
> Markus
>
> 2007/11/29, Mark Proctor <mproctor at codehaus.org>:
> >
> >  The src code is not kept. You would have to get this from the
> > PackageBuilder and the JavaDialect, which is  in the DialectRegistry. You'll
> > need to do this via reflection. When you get a reference to the mape it'll
> > be bytes  again, just do new String(byte[] bytes).
> >
> >  Mark
> >
> >  Markus Helbig wrote:
> >  I decompiled the class files, but there's sth curious in the Constant
> > Pool there is an invalid TagValue it is 97, it occurs in the
> > *ReturnValueInvoker Classes any idea what's 97 (or it should be mapped
> > to)?
> >
> > valid types are (as far as i know):
> >
> > CONSTANT_Class 7
> > CONSTANT_Fieldref 9
> > CONSTANT_Methodref 10
> > CONSTANT_InterfaceMethodref 11
> > CONSTANT_String 8
> > CONSTANT_Integer 3
> > CONSTANT_Float 4
> > CONSTANT_Long 5
> > CONSTANT_Double 6
> > CONSTANT_NameAndType 12
> > CONSTANT_Utf8 1
> >
> > Cheers
> >
> > Markus
> >
> > 2007/11/29, Markus Helbig <mhelbig81 at googlemail.com>:
> >
> >
> >  now i tried Mark's suggestion but this is also just bytecode i get ...
> > ok with byte code it would be possible to decompile ...
> >
> > Cheers
> >
> > Markus
> >
> > 2007/11/28, Darko IVANCAN <ivancan at gmx.de>:
> >
> >
> >  Hi,
> >
> > Obviously Mark's suggestion is better.
> >
> > Anyway: Seen, that the BRMS gives you a package (as .pkg) and the
> > RuleAgents can load those files and Packages are Serializable, I think
> > you want to investigate also in this possibility, by looking how current
> > DRools code is doing this job.
> >
> > Darko
> >
> > On 28/11/2007 16:00, Markus Helbig wrote:
> >
> >
> >  that's right, but can you read bytecode? Or is there a way to
> > serialize into pure Java Code,
> >
> > i think i'll try the way Mark provided ...
> >
> > Cheers
> >
> > Markus
> >
> > 2007/11/28, Darko IVANCAN <ivancan at gmx.de>:
> >
> >
> >
> >  Hi,
> >
> > The package can be serialized. See manual: deployment options.
> > The package can also be downloaded from the BRMS.
> >
> > Hope this helps,
> > Darko Ivancan
> >
> > On 28/11/2007 13:58, Markus Helbig wrote:
> >
> >
> >
> >  Hi,
> >
> > is there any possibility to get the compiled java code of the rules
> > ... could be helpful for several reasons ...
> >
> > Cheers
> >
> > Markus
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> >
> >
> >  _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> >  _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> >
> >  _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >  _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>



More information about the rules-users mailing list