@@ -246,13 +246,12 @@ public void addObject(final Object original, boolean immutableFromParent, final
246
246
* not seen - so this check actually protects against much more than just missing class
247
247
* initialization information.
248
248
*/
249
- throw VMError .shouldNotReachHere ("Image heap writing found a class not seen as instantiated during static analysis. " +
250
- "Did a static field or an object referenced from a static field change during native image generation? " +
251
- "For example, a lazily initialized cache could have been initialized during image generation, " +
252
- "in which case you need to force eager initialization of the cache before static analysis or reset the cache using a field value recomputation.\n " +
253
- " class: " + original + "\n " +
254
- " reachable through:\n " +
255
- fillReasonStack (new StringBuilder (), reason ));
249
+ throw VMError .shouldNotReachHere (String .format (
250
+ "Image heap writing found a class not seen as instantiated during static analysis. Did a static field or an object referenced " +
251
+ "from a static field change during native image generation? For example, a lazily initialized cache could have been " +
252
+ "initialized during image generation, in which case you need to force eager initialization of the cache before static analysis " +
253
+ "or reset the cache using a field value recomputation.%n class: %s%n reachable through:%n%s" ,
254
+ original , fillReasonStack (new StringBuilder (), reason )));
256
255
}
257
256
258
257
int identityHashCode ;
@@ -344,13 +343,13 @@ private void addObjectToBootImageHeap(final Object object, boolean immutableFrom
344
343
345
344
final Optional <HostedType > optionalType = getMetaAccess ().optionalLookupJavaType (object .getClass ());
346
345
if (!optionalType .isPresent () || !optionalType .get ().isInstantiated ()) {
347
- throw UserError .abort ("Image heap writing found an object whose class was not seen as instantiated during static analysis. " +
348
- "Did a static field or an object referenced from a static field change during native image generation? " +
349
- "For example, a lazily initialized cache could have been initialized during image generation, " +
350
- "in which case you need to force eager initialization of the cache before static analysis or reset the cache using a field value recomputation. \n " +
351
- " object: " + object + " of class: " + object . getClass (). getTypeName () + " \n " +
352
- " reachable through:\n " +
353
- fillReasonStack (new StringBuilder (), reason ));
346
+ throw UserError .abort (
347
+ String . format ( "Image heap writing found an object whose class was not seen as instantiated during static analysis. " +
348
+ "Did a static field or an object referenced from a static field change during native image generation? " +
349
+ "For example, a lazily initialized cache could have been initialized during image generation, in which case " +
350
+ "you need to force eager initialization of the cache before static analysis or reset the cache using a field " +
351
+ "value recomputation.%n object: %s of class: %s%n reachable through:%n%s" ,
352
+ object , object . getClass (). getTypeName (), fillReasonStack (new StringBuilder (), reason ) ));
354
353
}
355
354
final HostedType type = optionalType .get ();
356
355
final DynamicHub hub = type .getHub ();
@@ -558,20 +557,18 @@ private void mustBeReferenceAligned(int index) {
558
557
559
558
private static void verifyTargetDidNotChange (Object target , Object reason , Object targetInfo ) {
560
559
if (targetInfo == null ) {
561
- throw UserError .abort ("Static field or an object referenced from a static field changed during native image generation?\n " +
562
- " object:" + target + " of class: " + target .getClass ().getTypeName () + "\n " +
563
- " reachable through:\n " +
564
- fillReasonStack (new StringBuilder (), reason ));
560
+ throw UserError .abort (String .format ("Static field or an object referenced from a static field changed during native image generation?%n" +
561
+ " object:%s of class: %s%n reachable through:%n%s" , target , target .getClass ().getTypeName (), fillReasonStack (new StringBuilder (), reason )));
565
562
}
566
563
}
567
564
568
565
private static StringBuilder fillReasonStack (StringBuilder msg , Object reason ) {
569
566
if (reason instanceof ObjectInfo ) {
570
567
ObjectInfo info = (ObjectInfo ) reason ;
571
- msg .append (" object: " ).append (info .getObject ()).append (" of class: " ).append (info .getObject ().getClass ().getTypeName ()).append (" \n " );
568
+ msg .append (" object: " ).append (info .getObject ()).append (" of class: " ).append (info .getObject ().getClass ().getTypeName ()).append (System . lineSeparator () );
572
569
return fillReasonStack (msg , info .reason );
573
570
}
574
- return msg .append (" root: " ).append (reason ).append (" \n " );
571
+ return msg .append (" root: " ).append (reason ).append (System . lineSeparator () );
575
572
}
576
573
577
574
private void writeField (RelocatableBuffer buffer , ObjectInfo fields , HostedField field , JavaConstant receiver , ObjectInfo info ) {
@@ -1198,7 +1195,7 @@ void printHistogram() {
1198
1195
}
1199
1196
1200
1197
void printSize () {
1201
- System .out .printf ("PrintImageHeapPartitionSizes: partition: %s size: %d\ n " , name , getSize ());
1198
+ System .out .printf ("PrintImageHeapPartitionSizes: partition: %s size: %d% n" , name , getSize ());
1202
1199
}
1203
1200
1204
1201
private HeapPartition (String name , NativeImageHeap heap , boolean writable ) {
0 commit comments