Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Clojure:
- (ns test.example
- (:import (com.example Example)))
- (gen-class
- :name test.Example
- :extends com.example.Example
- :main false
- :exposes {PROTECTED_FIELD {:get PROTECTED_FIELD :set PROTECTED_FIELD}}
- :methods [[fieldInfo [] void]])
- (defn -init [this]
- [[] (atom {:PROTECTED_FIELD (.PROTECTED_FIELD this)})])
- (defn -fieldInfo [this]
- (println (.PROTECTED_FIELD this)))
- Java:
- package com.example;
- public class Example {
- protected static final String PROTECTED_FIELD = "this is a field";
- public void asdf() { }
- }
- More java:
- package tests;
- import java.lang.reflect.Constructor;
- import java.lang.reflect.Method;
- import test.Example;
- public class Tests {
- public static void main(String[] args) throws Exception {
- Example e = new Example();
- e.fieldInfo();
- /*
- Class c = Class.forName("test.Example");
- for (Constructor ctor : c.getConstructors()) {
- System.out.println("Constructor:");
- for (Class p : ctor.getParameterTypes()) {
- System.out.println(" " + p);
- }
- }
- for (Method m : c.getMethods()) {
- System.out.println(m.getName());
- for (Class p : m.getParameterTypes()) {
- System.out.println(" " + p);
- }
- }
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement