239 return getAllModifiers() & jvmMethodModifiers(); |
239 return getAllModifiers() & jvmMethodModifiers(); |
240 } |
240 } |
241 |
241 |
242 @Override |
242 @Override |
243 public boolean canBeStaticallyBound() { |
243 public boolean canBeStaticallyBound() { |
244 return (isFinal() || isPrivate() || isStatic() || holder.isLeaf()) && isConcrete(); |
244 return (isFinal() || isPrivate() || isStatic() || holder.isLeaf() || isConstructor()) && isConcrete(); |
245 } |
245 } |
246 |
246 |
247 @Override |
247 @Override |
248 public byte[] getCode() { |
248 public byte[] getCode() { |
249 if (getCodeSize() == 0) { |
249 if (getCodeSize() == 0) { |
404 return compilerToVM().getStackTraceElement(this, bci); |
404 return compilerToVM().getStackTraceElement(this, bci); |
405 } |
405 } |
406 |
406 |
407 @Override |
407 @Override |
408 public ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver) { |
408 public ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver) { |
|
409 assert !canBeStaticallyBound() : this; |
|
410 |
409 if (receiver.isInterface()) { |
411 if (receiver.isInterface()) { |
410 // Cannot trust interfaces. Because of: |
412 // Cannot trust interfaces. Because of: |
411 // interface I { void foo(); } |
413 // interface I { void foo(); } |
412 // class A { public void foo() {} } |
414 // class A { public void foo() {} } |
413 // class B extends A implements I { } |
415 // class B extends A implements I { } |
415 // class D extends B { } |
417 // class D extends B { } |
416 // Would lead to identify C.foo() as the unique concrete method for I.foo() without |
418 // Would lead to identify C.foo() as the unique concrete method for I.foo() without |
417 // seeing A.foo(). |
419 // seeing A.foo(). |
418 return null; |
420 return null; |
419 } |
421 } |
|
422 assert !receiver.isLinked() || isInVirtualMethodTable(receiver); |
420 if (this.isDefault()) { |
423 if (this.isDefault()) { |
421 // CHA for default methods doesn't work and may crash the VM |
424 // CHA for default methods doesn't work and may crash the VM |
422 return null; |
425 return null; |
423 } |
426 } |
424 return compilerToVM().findUniqueConcreteMethod(((HotSpotResolvedObjectTypeImpl) receiver), this); |
427 return compilerToVM().findUniqueConcreteMethod(((HotSpotResolvedObjectTypeImpl) receiver), this); |
470 long metaspaceMethodData = UNSAFE.getAddress(getMetaspaceMethod() + config().methodDataOffset); |
473 long metaspaceMethodData = UNSAFE.getAddress(getMetaspaceMethod() + config().methodDataOffset); |
471 if (metaspaceMethodData != 0) { |
474 if (metaspaceMethodData != 0) { |
472 methodData = new HotSpotMethodData(metaspaceMethodData, this); |
475 methodData = new HotSpotMethodData(metaspaceMethodData, this); |
473 String methodDataFilter = Option.TraceMethodDataFilter.getString(); |
476 String methodDataFilter = Option.TraceMethodDataFilter.getString(); |
474 if (methodDataFilter != null && this.format("%H.%n").contains(methodDataFilter)) { |
477 if (methodDataFilter != null && this.format("%H.%n").contains(methodDataFilter)) { |
475 System.out.println(methodData.toString()); |
478 String line = methodData.toString() + System.lineSeparator(); |
|
479 byte[] lineBytes = line.getBytes(); |
|
480 CompilerToVM.compilerToVM().writeDebugOutput(lineBytes, 0, lineBytes.length, true, true); |
476 } |
481 } |
477 } |
482 } |
478 } |
483 } |
479 |
484 |
480 if (methodData == null || (!methodData.hasNormalData() && !methodData.hasExtraData())) { |
485 if (methodData == null || (!methodData.hasNormalData() && !methodData.hasExtraData())) { |
505 return runtime().reflection.getParameters(this); |
510 return runtime().reflection.getParameters(this); |
506 } |
511 } |
507 |
512 |
508 @Override |
513 @Override |
509 public Annotation[][] getParameterAnnotations() { |
514 public Annotation[][] getParameterAnnotations() { |
510 if ((getConstMethodFlags() & config().constMethodHasParameterAnnotations) == 0) { |
515 if ((getConstMethodFlags() & config().constMethodHasParameterAnnotations) == 0 || isClassInitializer()) { |
511 return new Annotation[signature.getParameterCount(false)][0]; |
516 return new Annotation[signature.getParameterCount(false)][0]; |
512 } |
517 } |
513 return runtime().reflection.getParameterAnnotations(this); |
518 return runtime().reflection.getParameterAnnotations(this); |
514 } |
519 } |
515 |
520 |
516 @Override |
521 @Override |
517 public Annotation[] getAnnotations() { |
522 public Annotation[] getAnnotations() { |
518 if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0) { |
523 if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0 || isClassInitializer()) { |
519 return new Annotation[0]; |
524 return new Annotation[0]; |
520 } |
525 } |
521 return runtime().reflection.getMethodAnnotations(this); |
526 return runtime().reflection.getMethodAnnotations(this); |
522 } |
527 } |
523 |
528 |
524 @Override |
529 @Override |
525 public Annotation[] getDeclaredAnnotations() { |
530 public Annotation[] getDeclaredAnnotations() { |
526 if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0) { |
531 if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0 || isClassInitializer()) { |
527 return new Annotation[0]; |
532 return new Annotation[0]; |
528 } |
533 } |
529 return runtime().reflection.getMethodDeclaredAnnotations(this); |
534 return runtime().reflection.getMethodDeclaredAnnotations(this); |
530 } |
535 } |
531 |
536 |
532 @Override |
537 @Override |
533 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { |
538 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { |
534 if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0) { |
539 if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0 || isClassInitializer()) { |
535 return null; |
540 return null; |
536 } |
541 } |
537 return runtime().reflection.getMethodAnnotation(this, annotationClass); |
542 return runtime().reflection.getMethodAnnotation(this, annotationClass); |
538 } |
543 } |
539 |
544 |