code_junkie

Synthetic Class in Java

Nov 13th, 2011
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. class MyOuter {
  2.  
  3. private MyInner inner;
  4.  
  5. void createInner() {
  6. // The Compiler has to create a synthetic method
  7. // to construct a new MyInner because the constructor
  8. // is private.
  9. // --> synthetic "constructor" method
  10. inner = new MyInner();
  11.  
  12. // The Compiler has to create a synthetic method
  13. // to doSomething on MyInner object because this
  14. // method is private.
  15. // --> synthetic "constructor" method
  16. inner.doSomething();
  17. }
  18.  
  19. private class MyInner {
  20. // the inner class holds a syntetic ref_pointer to
  21. // the outer "parent" class
  22. // --> synthetic field
  23. private MyInner() {
  24. }
  25. private void doSomething() {
  26. }
  27. }
  28. }
  29.  
  30. //...
  31. Thread myThread = new Thread() {
  32. public void run() {
  33. // do something ...
  34. }
  35. };
  36. myThread.start();
  37. //...
Add Comment
Please, Sign In to add comment