Why did I get a java.lang.NoSuchMethodError? #1122
Unanswered
nyenggyang
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have the following line of code (below) in my program (where Figure ≡ tech.tablesaw.plotly.components.Figure, Histogram ≡ tech.tablesaw.plotly.api.Histogram and localCSVTable ≡ an instance of the class tech.tablesaw.api.Table):
Figure histogramFigure = Histogram.create("Histogram from Customer Table", localCSVTable, "fresh");
When I compiled the program containing the foregoing line of code (above), I got the java.lang.NoSuchMethodError pertaining to this line of code; the following gives the full exception report for this java.lang.NoSuchMethodError, which I obtained:
Exception in thread "main" java.lang.NoSuchMethodError: 'tech.tablesaw.api.NumberColumn tech.tablesaw.api.Table.numberColumn(java.lang.String)'
at tech.tablesaw.plotly.api.Histogram.create(Histogram.java:19)
at MiscTablesawFeaturesVisualization.main(MiscTablesawFeaturesVisualization.java:57)
The following is the description of the java.lang.NoSuchMethodError in the Java API:
"Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed."
According to (1) The foregoing description (above) of the java.lang.NoSuchMethodError in the Java API as well as (2) The details of the particular exception report above, which I obtained from compiling my program, the class tech.tablesaw.api.Table does not have the method numberColumn(java.lang.String). However, while it is true that the class tech.tablesaw.api.Table does not have the method numberColumn(java.lang.String), this class nonetheless inherits this method from the class tech.tablesaw.table.Relation.
Furthermore, the code in the implementation of the class tech.tablesaw.plotly.api.Histogram shows that the 3-parameter method create(java.lang.String title, tech.tablesaw.api.Table table, java.lang.String numericColumnName) of this class simply does the following:
(3.) The method uses the tech.tablesaw.api.Table instance, which is passed to it as an argument, to invoke the method numberColumn(java.lang.String) that this instance inherits from the class tech.tablesaw.table.Relation; the argument, which is passed to this invoked method numberColumn(java.lang.String), is the third java.lang.String argument that is passed to the method create(java.lang.String title, tech.tablesaw.api.Table table, java.lang.String numericColumnName) and this invocation of the method numberColumn(java.lang.String) returns an instance of the type tech.tablesaw.api.NumericColumn<?>.
(4.) The method then invokes the overloaded 2-parameter method create(java.lang.String title, tech.tablesaw.api.NumericColumn data) of the same class tech.tablesaw.plotly.api.Histogram; the two arguments that are passed to this invoked overloaded method create(java.lang.String title, tech.tablesaw.api.NumericColumn data) are (A) The first java.lang.String argument that is passed to the 3-parameter method create(java.lang.String title, tech.tablesaw.api.Table table, java.lang.String numericColumnName) and (B) The instance of the type tech.tablesaw.api.NumericColumn<?> that is returned from the invocation of the method numberColumn(java.lang.String), as explained in the point number 3 above.
Since the class tech.tablesaw.api.Table inherits the method numberColumn(java.lang.String) from the class tech.tablesaw.table.Relation, I do not think that I should get the java.lang.NoSuchMethodError, which I got as shown in the exception report that I copied and pasted above (recall that the description of the java.lang.NoSuchMethodError in the Java API goes thus: "Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.")
Beta Was this translation helpful? Give feedback.
All reactions