sebastiandietrich / privilegedaccessor Goto Github PK
View Code? Open in Web Editor NEWLibrary to access private or protected parts of java classes
Home Page: http://sebastiandietrich.github.io/privilegedaccessor/
License: Other
Library to access private or protected parts of java classes
Home Page: http://sebastiandietrich.github.io/privilegedaccessor/
License: Other
... because PrivilegedAccessor is marked as Deprecated.
Attantion: invokeMethod(final Object instanceOrClass, final String
methodSignature, final Object... arguments) is not 1:1 delegation, because
Object... are changed into Object[] in StrictPA.
Original issue reported on code.google.com by [email protected]
on 18 Mar 2012 at 3:34
description copied from sourceforge:
Hi.
I've repackaged the existing source to use Ant to generate the jar, javadocs
and distribution versions. The java source files themselves are completely
unchanged, however they were separated into main and test sub-folders.
The ant build.xml file can also run the junit tests, after pulling down the
junit library using Ivy.
Please see the attached zip file.
E.
Original issue reported on code.google.com by [email protected]
on 18 Feb 2012 at 11:23
see http://code.google.com/p/maven-gcu-plugin/wiki/Usage
Original issue reported on code.google.com by [email protected]
on 19 Feb 2012 at 8:54
What steps will reproduce the problem?
1. write a private method than expects an int[]
2. call it with PA.invokeMethod
Should work as expected, throws exception instead
public void testAutoboxing() throws Exception {
int[] Ints = new int[] {1, 2, 3};
PA.invokeMethod(this.child, "setPrivateInts(int[])", Ints);
assertEquals(Ints, PA.getValue(this.child, "privateInts"));
}
Original issue reported on code.google.com by [email protected]
on 1 Jun 2013 at 3:48
Would you please support this case:
public class MyClass {
// My private method throws a exception
private int myPrivateMethod(int p) throws MyException {
throw new MyException();
}
}
// This test expects MyException
@Test(expected = MyException.class)
public void testMyPrivateMethod() {
PA.invokeMethod(myInstance, "myPrivateMethod", 0);
}
Original issue reported on code.google.com by [email protected]
on 8 Aug 2013 at 3:25
description copied from sourceforge:
Hi,
I downloaded PA and have started using it at work, but
found I couldn't pass arrays of any type as arguments
to methods. A small modification to
PrivilegedAccessor.java makes this possible.
It's a little bit hacky (have to instantiate an array
object and call getClass() ) but it works. You can
avoid object instantiation for arrays of primitives,
but didn't bother, it was more code for no extra value.
I created a bunch of tests while I was working this
out, so I thought I might as well attach them as well.
There's probably some duplication with you current
tests, I haven't really checked, but I'll clean them up
later if you're interested in keeping them.
... Actually not, I can only attach one file. I can
send them on later if you like.
I'd also like to add some handling for inner classes,
and have some ideas brewing for extending the API if
you would be interested.
Cheers,
nut
Original issue reported on code.google.com by [email protected]
on 18 Feb 2012 at 11:20
e.g. the following code does not work:
PA.setValue(String.class, "serialVersionUID", 1); //sets the static final field
serialVersionUID
Original issue reported on code.google.com by [email protected]
on 26 Feb 2012 at 10:15
Either replace checked Exceptions with RuntimeException or add new methods not
declaring checked exceptions.
Original issue reported on code.google.com by [email protected]
on 19 Feb 2012 at 8:58
E.g.
PA.new(insatnce).value("fieldName", value).method("methodName", arguments)
OR
PA.new(instance).field("fieldName").value(value).method("methodName").arguments(
arguments)
OR
PA.new(instance).f("fieldName").v(value).m("methodName").a(arguments)
Original issue reported on code.google.com by [email protected]
on 19 Feb 2012 at 9:01
What steps will reproduce the problem?
1. write a class with a private method with varargs
2. try to call that method from outside of that class using PA
3. you will get an IllegalArgumentException based on a NoSuchMethodException
What is the expected output? What do you see instead?
should run fine and call that method
Testcase in PATest that shows that functionality:
public void testInvokeMethodWithVarargs() throws Exception {
PA.invokeMethod(this.parent, "setNamesWithVarargs(String...)", "Charly", "Browne");
assertEquals("Charly", PA.getValue(this.parent, "privateName"));
assertEquals("Browne", PA.getValue(this.parent, "privateObject"));
}
Original issue reported on code.google.com by [email protected]
on 23 Apr 2013 at 9:18
This should not work and instead throw an IllegalArgumentException
This is a bug in PA and not in PrivilegedAccessor, since PA works with varargs,
while PrivilegedAccessor works with Object[]
Original issue reported on code.google.com by [email protected]
on 21 Feb 2012 at 9:21
There is not licence nor in jar neither in source files.
Original issue reported on code.google.com by [email protected]
on 2 Mar 2012 at 11:59
What steps will reproduce the problem?
1. private constructor expecting primitives (e.g. int, float)
2. try to call it using primitives or object types
3. does not work since varargs are converted to object types
Original issue reported on code.google.com by [email protected]
on 25 Sep 2013 at 4:32
getMethodSignatures() returns the method name and arguments. It would be
helpful to have a version of this getMethodSignaturesWithReturnType() that also
includes the return type in the String.
Examples of data returned in the existing method are:
getMethodSignatures()
wait()
wait(long)
registerNatives()
equals(java.lang.Object)
Here are versions of those same methods using the new method
getMethodSignaturesWithReturnType()
void wait()
void wait(long)
void registerNatives()
boolean equals(java.lang.Object)
Attached is an implementation of this new method in PrivilegedAccessor and PA
as well as their associated test classes. The code is based on the trunk
version of these files.
Original issue reported on code.google.com by [email protected]
on 29 May 2014 at 3:33
Attachments:
copied from old sourceforge location:
The PA could access Fields and invoke methodes only if
the names are KNOWN.
For this the PA should contain methods to get this names.
I would suggest to implement new features like :
List getFieldNames(Object obj)
List getMethodNames(Object obj)
and for further Information methods like this:
getInformation(<fieldOrMethodname>)
which creates an output like this:
private long <fieldOrMethodname> = 33
protected java.lang.String uppercase(java.lang.String
string)
Perhaps a "scanObject" Method could be useful, which
shows all Fields and methods from the Object like this:
this.is.my.package.structure.Person:
Fields:
private java.lang.String name = "this is the name"
private int age = 33
...
Methods:
public java.lang.String getName()
protected java.lang.String
uppercase(java.lang.String string)
...
best regards,
Matthias Herp
Original issue reported on code.google.com by [email protected]
on 18 Feb 2012 at 11:16
automatically deploy snapshots to maven central
semi-automatically deploy releases to maven central
see
https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage
+Guide
P.S. continuous delivery is IMHO not a good idea for libraries/frameworks
Original issue reported on code.google.com by [email protected]
on 19 Feb 2012 at 8:30
Groovy like Expand - dynamically defining object structure/behaviour.
PA.newExpando().field("fieldName").value(value)
Original issue reported on code.google.com by [email protected]
on 19 Feb 2012 at 9:04
PA.instantiate("java.lang.String").getValue("value"); // returns the private
final character storage
should be possible by returnig a dynamic proxy to String
but this proxy should behave like the original class, i.e.
PA.instantiate("java.lang.String").hashCode(); should still work
Original issue reported on code.google.com by [email protected]
on 19 Apr 2013 at 7:47
invokeMethod() with Object[] is currently not supported (since varargs are
converted to Object[])
find a solution for that
Original issue reported on code.google.com by [email protected]
on 19 Feb 2012 at 9:09
What steps will reproduce the problem?
1. define a private constructor with an array argument
2. try to invoke that constructor using PA
3. you'll get an IllegalArgumentException
What is the expected output? What do you see instead?
Constructor should be called fine without exeption
Unit-Test:
assertEquals(this.child, PA.instantiate(Child.class, new Class[]
{String[].class}, new String[] {"Charlie", "Browne"}));
Original issue reported on code.google.com by [email protected]
on 23 Apr 2013 at 9:44
description copied from old sourceforge repository:
final java.lang.reflect.Method m = Database.class.getDeclaredMethod(init,
File.class);
m.setAccessible(true);
m.invoke(Database.class, dir);
//PrivilegedAccessor.invokeMethod(Database.class,"init(final File dir)", dir);
The commented line should have the same effect as the 3 reflect above it.
However, that's no the case. Why?
The code is on:
http://memorizeasy.googlecode.com/svn-history/r94/trunk/MemorizEasy/src/com/mysi
mpatico/memorizeasy/test/DatabaseTest.java
http://memorizeasy.googlecode.com/svn-history/r94/trunk/MemorizEasy/src/com/mysi
mpatico/memorizeasy/engine/Database.java
Original issue reported on code.google.com by [email protected]
on 18 Feb 2012 at 11:13
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.