AOSP art.module.platform.api.stubs compile failed (NaN java error)

Failed to build aosp
[  0% 18/12890] //libcore/mmodules/core_platform_api:art.module.platform.api.stubs javac [common]
FAILED: out/soong/.intermediates/libcore/mmodules/core_platform_api/art.module.platform.api.stubs/android_common/javac/art.module.platform.api.stubs.jar

out/soong/.intermediates/libcore/mmodules/core_platform_api/art.module.platform.api.stubs/android_common/javac/srcjars/java/lang/Double.java:106: error: self-reference in initializer
public static final double NaN = NaN;
                                 ^
out/soong/.intermediates/libcore/mmodules/core_platform_api/art.module.platform.api.stubs/android_common/javac/srcjars/java/lang/Float.java:108: error: cannot find symbol
public static final float NaN = NaNf;
                                ^
  symbol:   variable NaNf   
  location: class Float
2 errors

In every file Double.java file NaN = 0.0d / 0.0; After I am trying to modify theese files, build regenerate them with same error. Where is this files locate in sources and how to fix theese errors? Thanks for answers.

Upvotes: 0

Views: 288

Answers (1)

Henry Pootle
Henry Pootle

Reputation: 1216

They are from metalava.

File src/main/java/com/android/tools/metalava/model/FieldItem.kt

I bet you've updated kotlinc so the code now doesn't work as expected. There are two sections there. One for Double and one for Float. Both don't work as expected with kotlin 1.5+

So you should replace

is Float -> {
  writer.print(" = ")
  when (value) {
     Float.POSITIVE_INFINITY -> writer.print("(1.0f/0.0f);")
     Float.NEGATIVE_INFINITY -> writer.print("(-1.0f/0.0f);")
     Float.NaN -> writer.print("(0.0f/0.0f);")
  }
}

by

is Float -> {
  writer.print(" = ")
  when {
    value == Float.POSITIVE_INFINITY -> writer.print("(1.0f/0.0f);")
    value == Float.NEGATIVE_INFINITY -> writer.print("(-1.0f/0.0f);")
    java.lang.Float.isNaN(value) -> writer.print("(0.0f/0.0f);")
    else -> { 
      writer.print(canonicalizeFloatingPointString(value.toString()))
      writer.print("f;")
    }
  }
}

and same for Double, replace the block

 is Double -> {
   writer.print(" = ")
   when (value) {
     Double.POSITIVE_INFINITY -> writer.print("(1.0/0.0);")
     Double.NEGATIVE_INFINITY -> writer.print("(-1.0/0.0);")
     Double.NaN -> writer.print("(0.0/0.0);")
     else -> { 
       writer.print(canonicalizeFloatingPointString(value.toString()))
       writer.print(";")
     }
   }
 }

by

 is Double -> {
     writer.print(" = ")
     when {
         value == Double.POSITIVE_INFINITY -> writer.print("(1.0/0.0);")
         value == Double.NEGATIVE_INFINITY -> writer.print("(-1.0/0.0);")
         java.lang.Double.isNaN(value) -> writer.print("(0.0/0.0);")
         else -> {
             writer.print(canonicalizeFloatingPointString(value.toString()))
             writer.print(";")
         }
     }
 }

Upvotes: 0

Related Questions