You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InitializerSignatureImpl.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/epl-v10.html
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * ******************************************************************/
  13. package org.aspectj.runtime.reflect;
  14. import org.aspectj.lang.reflect.InitializerSignature;
  15. import java.lang.reflect.Constructor;
  16. import java.lang.reflect.Modifier;
  17. class InitializerSignatureImpl extends CodeSignatureImpl implements InitializerSignature {
  18. private Constructor constructor;
  19. InitializerSignatureImpl(int modifiers, Class declaringType) {
  20. super(modifiers, Modifier.isStatic(modifiers) ? "<clinit>" : "<init>", declaringType, EMPTY_CLASS_ARRAY,
  21. EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY);
  22. }
  23. InitializerSignatureImpl(String stringRep) {
  24. super(stringRep);
  25. }
  26. public String getName() {
  27. return Modifier.isStatic(getModifiers()) ? "<clinit>": "<init>";
  28. }
  29. protected String createToString(StringMaker sm) {
  30. StringBuffer buf = new StringBuffer();
  31. buf.append(sm.makeModifiersString(getModifiers()));
  32. buf.append(sm.makePrimaryTypeName(getDeclaringType(),getDeclaringTypeName()));
  33. buf.append(".");
  34. buf.append(getName());
  35. return buf.toString();
  36. }
  37. /* (non-Javadoc)
  38. * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject()
  39. */
  40. public Constructor getInitializer() {
  41. if (constructor == null) {
  42. try {
  43. constructor = getDeclaringType().getDeclaredConstructor(getParameterTypes());
  44. } catch (Exception ex) {
  45. ; // nothing we can do, caller will see null
  46. }
  47. }
  48. return constructor;
  49. }
  50. }