Advertisement
Guest User

gen-class exposes

a guest
Oct 16th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. Clojure:
  2.  
  3. (ns test.example
  4. (:import (com.example Example)))
  5.  
  6. (gen-class
  7. :name test.Example
  8. :extends com.example.Example
  9. :main false
  10. :exposes {PROTECTED_FIELD {:get PROTECTED_FIELD :set PROTECTED_FIELD}}
  11. :methods [[fieldInfo [] void]])
  12.  
  13. (defn -init [this]
  14. [[] (atom {:PROTECTED_FIELD (.PROTECTED_FIELD this)})])
  15.  
  16. (defn -fieldInfo [this]
  17. (println (.PROTECTED_FIELD this)))
  18.  
  19. Java:
  20.  
  21. package com.example;
  22.  
  23. public class Example {
  24.  
  25. protected static final String PROTECTED_FIELD = "this is a field";
  26.  
  27. public void asdf() { }
  28. }
  29.  
  30. More java:
  31.  
  32. package tests;
  33.  
  34. import java.lang.reflect.Constructor;
  35. import java.lang.reflect.Method;
  36.  
  37. import test.Example;
  38.  
  39. public class Tests {
  40.  
  41. public static void main(String[] args) throws Exception {
  42. Example e = new Example();
  43. e.fieldInfo();
  44. /*
  45. Class c = Class.forName("test.Example");
  46. for (Constructor ctor : c.getConstructors()) {
  47. System.out.println("Constructor:");
  48. for (Class p : ctor.getParameterTypes()) {
  49. System.out.println(" " + p);
  50. }
  51. }
  52. for (Method m : c.getMethods()) {
  53. System.out.println(m.getName());
  54. for (Class p : m.getParameterTypes()) {
  55. System.out.println(" " + p);
  56. }
  57. }
  58. */
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement