File: InlineJavaUserClassLink.java

package info (click to toggle)
libinline-java-perl 0.67-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 716 kB
  • sloc: perl: 3,817; java: 2,621; makefile: 35; sh: 1
file content (45 lines) | stat: -rw-r--r-- 1,229 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.util.* ;
import java.lang.reflect.* ;


public class InlineJavaUserClassLink {
	public InlineJavaUserClassLink(){
	}


	public Object invoke(Method m, Object o, Object p[]) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		return m.invoke(o, p) ;
	}


	public Object get(Field f, Object o) throws IllegalAccessException, IllegalArgumentException {
		return f.get(o) ;
	}


	public void set(Field f, Object o, Object p) throws IllegalAccessException, IllegalArgumentException {
		f.set(o, p) ;
	}


	public Object array_get(Object o, Integer idx){
		return Array.get(o, idx.intValue()) ;
	}


	public void array_set(Object o, Integer idx, Object elem) throws IllegalArgumentException {
		Array.set(o, idx.intValue(), elem) ;
	}


	public Object create(Class<?> p, Object args[], Class proto[]) throws NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		// This will allow usage of the default no-arg constructor
		if (proto.length == 0){
			return p.getDeclaredConstructor().newInstance() ;
		}
		else{
			Constructor con = (Constructor)p.getConstructor(proto) ;
			return con.newInstance(args) ;
		}
	}
}