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.

ConstructorSignatureImpl.java 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 v 2.0
  7. * which accompanies this distribution and is available at
  8. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * ******************************************************************/
  13. package org.aspectj.runtime.reflect;
  14. import java.lang.reflect.Constructor;
  15. import org.aspectj.lang.reflect.ConstructorSignature;
  16. class ConstructorSignatureImpl extends CodeSignatureImpl implements ConstructorSignature {
  17. private Constructor<?> constructor;
  18. ConstructorSignatureImpl(int modifiers, Class<?> declaringType,
  19. Class[] parameterTypes, String[] parameterNames, Class[] exceptionTypes)
  20. {
  21. super(modifiers, "<init>", declaringType, parameterTypes, parameterNames, exceptionTypes);
  22. }
  23. ConstructorSignatureImpl(String stringRep) {
  24. super(stringRep);
  25. }
  26. public String getName() { return "<init>"; }
  27. protected String createToString(StringMaker sm) {
  28. StringBuffer buf = new StringBuffer();
  29. buf.append(sm.makeModifiersString(getModifiers()));
  30. buf.append(sm.makePrimaryTypeName(getDeclaringType(),getDeclaringTypeName()));
  31. sm.addSignature(buf, getParameterTypes());
  32. sm.addThrows(buf, getExceptionTypes());
  33. return buf.toString();
  34. }
  35. /* (non-Javadoc)
  36. * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject()
  37. */
  38. public Constructor getConstructor() {
  39. if (constructor == null) {
  40. try {
  41. constructor = getDeclaringType().getDeclaredConstructor(getParameterTypes());
  42. } catch (Exception ex) {
  43. ; // nothing we can do, caller will see null
  44. }
  45. }
  46. return constructor;
  47. }
  48. }