question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Java interop with finagle 7 emits "malformed variable arity method: addGauge$"

See original GitHub issue

In working to update finagle zipkin to finagle 7 (https://github.com/openzipkin/zipkin-finagle/pull/35) we are seeing that the compiler complains about a malformed variable arity method: addGauge$

Expected behavior

Compilation succeeds

Actual behavior

Compilation fails

Steps to reproduce the behavior

The project in the PR easily reproduces the issue by just accessing import com.twitter.finagle.stats.StatsReceiver; in java. The full compilation error is:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/devshorts/src/zipkin-finagle/core/src/main/java/zipkin/finagle/ReporterMetricsAdapter.java:[18,33] cannot access com.twitter.finagle.stats.StatsReceiver
  bad class file: /Users/devshorts/.m2/repository/com/twitter/util-stats_2.12/7.0.0/util-stats_2.12-7.0.0.jar(/com/twitter/finagle/stats/StatsReceiver.class)
    class file contains malformed variable arity method: addGauge$(com.twitter.finagle.stats.StatsReceiver,java.lang.String[],scala.Function0)
    Please remove or make sure it appears in the correct subdirectory of the classpath.
[INFO] 1 error

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
vkostyukovcommented, Aug 21, 2017

Thanks @devshorts!

I downloaded the util-stats-7.0.0 package for 2.12 and checked it against javap. Indeed there is a static addGauge$ method there: https://gist.github.com/vkostyukov/1ac96e29684c7345bd16d2db59c1d732

I honestly have no idea why

  1. scalac generated that static forwarder
  2. javac isn’t happy about it

Will keep digging.

1reaction
vkostyukovcommented, Aug 21, 2017

I’m getting somewhere. These $-prefixed methods are coming from Scala 2.12. Here is the relevant piece of SR compiled against 2.11.11:

  public abstract com.twitter.finagle.stats.Gauge addGauge(java.lang.String..., scala.Function0<java.lang.Object>);
  public abstract com.twitter.finagle.stats.Gauge addGauge(com.twitter.finagle.stats.Verbosity, java.lang.String..., scala.Function0<java.lang.Object>);
  public abstract com.twitter.finagle.stats.Gauge addGauge(scala.collection.Seq<java.lang.String>, scala.Function0<java.lang.Object>);
  public abstract com.twitter.finagle.stats.Gauge addGauge(com.twitter.finagle.stats.Verbosity, scala.collection.Seq<java.lang.String>, scala.Function0<java.lang.Object>);

Here is the same, but for Scala 2.12.1:

  public static com.twitter.finagle.stats.Gauge addGauge$(com.twitter.finagle.stats.StatsReceiver, java.lang.String..., scala.Function0);
  public com.twitter.finagle.stats.Gauge addGauge(java.lang.String..., scala.Function0<java.lang.Object>);
  public static com.twitter.finagle.stats.Gauge addGauge$(com.twitter.finagle.stats.StatsReceiver, com.twitter.finagle.stats.Verbosity, java.lang.String..., scala.Function0);
  public com.twitter.finagle.stats.Gauge addGauge(com.twitter.finagle.stats.Verbosity, java.lang.String..., scala.Function0<java.lang.Object>);

  public static com.twitter.finagle.stats.Gauge addGauge$(com.twitter.finagle.stats.StatsReceiver, scala.collection.Seq, scala.Function0);
  public com.twitter.finagle.stats.Gauge addGauge(scala.collection.Seq<java.lang.String>, scala.Function0<java.lang.Object>);
  public abstract com.twitter.finagle.stats.Gauge addGauge(com.twitter.finagle.stats.Verbosity, scala.collection.Seq<java.lang.String>, scala.Function0<java.lang.Object>);

@kevinoliver pointed out that this could be related to 58c1d00679d23d6210be3f71e20739192545552b so var-arg isn’t in the final position now. yet we have a Java compilation test that compiles perfectly with both 2.11 and 2.12.

Read more comments on GitHub >

github_iconTop Results From Across the Web

class file contains malformed variable arity method for vararg ...
JDK11 compiler can't process a class file produced by kotlin compiler for a vararg constructor of a sealed class. See the following example....
Read more >
Java Interop与FinAGLE 7发出“格式错误的变量ARINE方法 ...
标题: Java Interop与FinAGLE 7发出“格式错误的变量ARINE方法:Addgauge $”. Java interop with finagle 7 emits "malformed variable arity method: addGauge$".
Read more >
Javadoc complains about bad class file, while compile and ...
(com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: ./example/Foo$1.class class file contains malformed variable arity method: (java.lang.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found