Way to print type inference engine progress?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Way to print type inference engine progress?

cesar
Hey there,

I'm debugging a portion of Java 11 code that seems to be hitting a problem like the bugs reported here [1][2]. I'm not very familiar with javac internals so I'm wondering if there is a way to make the type inference engine operate in verbose mode so I can get a list of type/constraints that it resolved during the evaluation of a Java statement.

I have a piece of code similar to the one below and I wanted to see all types the engine considered for each method:

Workflow<Map<FeatureSourceKey, Document<?>>> result = Workflow
    .value(strs)
    .flatMap(operator)
    .map(
        batchResult -> batchResult
        .values()
        .stream()
        .map(item -> getReMixBulkResponseItemValue(item))
        .collect(Collectors.toMap(d -> null, Function.identity())));

Is this possible?
 

Thanks,
Cesar

[1] https://bugs.openjdk.java.net/browse/JDK-8222171
[2] https://bugs.openjdk.java.net/browse/JDK-8222035
Reply | Threaded
Open this post in threaded view
|

Re: Way to print type inference engine progress?

Maurizio Cimadamore
Hi Cesar,
There should be an option:

"-Ddebug.dumpInferenceGraphsTo=<folder-name>"

which should generate a lot of .dot files showing constraints and
dependencies between inference variables. The option generates a ton of
output though, so it might take a while to figure out what graph you are
staring at.

Cheers
Maurizio

On 02/02/2021 01:31, Cesar Soares Lucas wrote:

> Hey there,
>
> I'm debugging a portion of Java 11 code that seems to be hitting a problem like the bugs reported here [1][2]. I'm not very familiar with javac internals so I'm wondering if there is a way to make the type inference engine operate in verbose mode so I can get a list of type/constraints that it resolved during the evaluation of a Java statement.
>
> I have a piece of code similar to the one below and I wanted to see all types the engine considered for each method:
>
> Workflow<Map<FeatureSourceKey, Document<?>>> result = Workflow
>      .value(strs)
>      .flatMap(operator)
>      .map(
>          batchResult -> batchResult
>          .values()
>          .stream()
>          .map(item -> getReMixBulkResponseItemValue(item))
>          .collect(Collectors.toMap(d -> null, Function.identity())));
>
> Is this possible?
>  
>
> Thanks,
> Cesar
>
> [1] https://bugs.openjdk.java.net/browse/JDK-8222171
> [2] https://bugs.openjdk.java.net/browse/JDK-8222035


Reply | Threaded
Open this post in threaded view
|

Re: Way to print type inference engine progress?

cesar
Thank you, Maurizio. That was helpful!

From: Maurizio Cimadamore <[hidden email]>
Sent: February 2, 2021 3:10 AM
To: Cesar Soares Lucas <[hidden email]>; [hidden email] <[hidden email]>
Subject: Re: Way to print type inference engine progress?
 
Hi Cesar,
There should be an option:

"-Ddebug.dumpInferenceGraphsTo=<folder-name>"

which should generate a lot of .dot files showing constraints and
dependencies between inference variables. The option generates a ton of
output though, so it might take a while to figure out what graph you are
staring at.

Cheers
Maurizio

On 02/02/2021 01:31, Cesar Soares Lucas wrote:
> Hey there,
>
> I'm debugging a portion of Java 11 code that seems to be hitting a problem like the bugs reported here [1][2]. I'm not very familiar with javac internals so I'm wondering if there is a way to make the type inference engine operate in verbose mode so I can get a list of type/constraints that it resolved during the evaluation of a Java statement.
>
> I have a piece of code similar to the one below and I wanted to see all types the engine considered for each method:
>
> Workflow<Map<FeatureSourceKey, Document<?>>> result = Workflow
>      .value(strs)
>      .flatMap(operator)
>      .map(
>          batchResult -> batchResult
>          .values()
>          .stream()
>          .map(item -> getReMixBulkResponseItemValue(item))
>          .collect(Collectors.toMap(d -> null, Function.identity())));
>
> Is this possible?
>  
>
> Thanks,
> Cesar
>
> [1] https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.openjdk.java.net%2Fbrowse%2FJDK-8222171&amp;data=04%7C01%7CDivino.Cesar%40microsoft.com%7C08cccf30a24348ec144508d8c76b69a3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637478611436273106%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=Vetuhk1Rhps%2BPll6xN9BcqRcdm35BRQVHfcuEk5l0t8%3D&amp;reserved=0
> [2] https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.openjdk.java.net%2Fbrowse%2FJDK-8222035&amp;data=04%7C01%7CDivino.Cesar%40microsoft.com%7C08cccf30a24348ec144508d8c76b69a3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637478611436273106%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=oEGyG%2FY2fn2oFtn3cAnh%2FWPdpsHd47Zme1TGCGOGC9E%3D&amp;reserved=0