Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency conflicts on com.fasterxml.jackson.core:jackson-core, leading to invoking unexpected methods #550

Open
HelloCoCooo opened this issue Jan 18, 2020 · 1 comment

Comments

@HelloCoCooo
Copy link

HelloCoCooo commented Jan 18, 2020

Hi, @cogmission, in htm.java-0.6.13-alpha, duplicate classes with the same fully-qualified name com.fasterxml.jackson.core.json.JsonWriteContext are included in two different libraries, i.e., com.fasterxml.jackson.core:jackson-core:2.5.3 and com.fasterxml.jackson.core:jackson-core:2.4.4.

According to "first declaration wins" class loading strategy, only this class in com.fasterxml.jackson.core:jackson-core:2.4.4 can be loaded, and that in com.fasterxml.jackson.core:jackson-core:2.5.3 will be shadowed.

By further analyzing, your project expects to invoke method <com.fasterxml.jackson.core.json.JsonWriteContext: writeFieldName(Ljava/lang/String;)I> in com.fasterxml.jackson.core:jackson-core:2.5.3. As it has been shadowed, so that this method defined in com.fasterxml.jackson.core:jackson-core:2.4.4 is actually forced to be referenced via the following invocation path:

<org.numenta.nupic.encoders.MultiEncoder: setLearning(Z)V> /home/wwww/sensor/unzip/htm.java-0.6.13-alpha/target/classes
<com.fasterxml.jackson.databind.MappingIterator: next()Ljava/lang/Object;> /home/wwww/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.4.4/jackson-databind-2.4.4.jar
<com.fasterxml.jackson.databind.MappingIterator: nextValue()Ljava/lang/Object;> /home/wwww/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.4.4/jackson-databind-2.4.4.jar
<com.fasterxml.jackson.databind.deser.BeanDeserializer: deserialize(Lcom/fasterxml/jackson/core/JsonParser;Lcom/fasterxml/jackson/databind/DeserializationContext;Ljava/lang/Object;)Ljava/lang/Object;> /home/wwww/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.4.4/jackson-databind-2.4.4.jar
<com.fasterxml.jackson.databind.deser.BeanDeserializer: deserializeWithUnwrapped(Lcom/fasterxml/jackson/core/JsonParser;Lcom/fasterxml/jackson/databind/DeserializationContext;Ljava/lang/Object;)Ljava/lang/Object;> /home/wwww/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.4.4/jackson-databind-2.4.4.jar
<com.fasterxml.jackson.databind.util.TokenBuffer: writeFieldName(Ljava/lang/String;)V> /home/wwww/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.4.4/jackson-databind-2.4.4.jar
<com.fasterxml.jackson.core.json.JsonWriteContext: writeFieldName(Ljava/lang/String;)I>

Although both of these two conflicting classes contain the referenced methods (with the same signature), they have different implementations. This issue will not lead to runtime crashes, but it can introduce inconsistent semantic hehavior by changing the control flows and data flows.

Workaround solution:
Use the newer version com.fasterxml.jackson.core:jackson-core:2.5.3 com.fasterxml.jackson.core:jackson-annotations:jar:2.5.3:compile com.fasterxml.jackson.core:jackson-databind:jar:2.5.3:compile to keep the version consistency.

Dependency tree--

[INFO] org.numenta:htm.java:jar:0.6.13
[INFO] +- joda-time:joda-time:jar:2.5:compile
[INFO] +- com.chaschev:chutils:jar:1.4:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] | - org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- net.sf.trove4j:trove4j:jar:3.0.3:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.4.4:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.4.4:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.4.4:compile
[INFO] | +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.4.0:compile - omitted for conflict with 2.4.4)
[INFO] | - (com.fasterxml.jackson.core:jackson-core:jar:2.4.4:compile - omitted for duplicate)
[INFO] +- org.slf4j:slf4j-api:jar:1.7.10:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.2:test
[INFO] | +- ch.qos.logback:logback-core:jar:1.1.2:test
[INFO] | - (org.slf4j:slf4j-api:jar:1.7.6:test - omitted for conflict with 1.7.10)
[INFO] +- io.reactivex:rxjava:jar:1.0.10:compile
[INFO] +- com.cedarsoftware:java-util:jar:1.19.3:compile
[INFO] | +- org.apache.logging.log4j:log4j-api:jar:2.1:compile
[INFO] | - org.apache.logging.log4j:log4j-core:jar:2.1:compile
[INFO] | - (org.apache.logging.log4j:log4j-api:jar:2.1:compile - omitted for duplicate)
[INFO] +- de.ruedigermoeller:fst:jar:2.45:compile
[INFO] | +- (com.fasterxml.jackson.core:jackson-core:jar:2.5.3:compile - omitted for conflict with 2.4.4)
[INFO] | +- org.javassist:javassist:jar:3.19.0-GA:compile
[INFO] | - org.objenesis:objenesis:jar:2.1:compile
[INFO] +- org.openjdk.jmh:jmh-core:jar:1.11.3:compile
[INFO] | +- net.sf.jopt-simple:jopt-simple:jar:4.6:compile
[INFO] | - org.apache.commons:commons-math3:jar:3.2:compile
[INFO] - algorithmfoundry:algorithmfoundry-shade-culled:jar:1.3:compile

Thank you very much.
Best,
Coco

@HelloCoCooo
Copy link
Author

Code snippet of :<com.fasterxml.jackson.core.json.JsonWriteContext: writeFieldName(Ljava/lang/String;)I> in com.fasterxml.jackson.core:jackson-core:2.5.3 (shadowed but expected to invoke method):

public int writeFieldName(String name) throws JsonProcessingException {		//line:152
  if (_gotName) {
    return JsonWriteContext.STATUS_EXPECT_VALUE;
  }
  _gotName = true;
  _currentName = name;
  if (_dups != null) { _checkDup(_dups, name); }
  return (_index < 0) ? STATUS_OK_AS_IS : STATUS_OK_AFTER_COMMA;
}

Code snippet of**:<com.fasterxml.jackson.core.json.JsonWriteContext: writeFieldName(Ljava/lang/String;)I>** in com.fasterxml.jackson.core:jackson-core:2.4.4 (loaded version):

public final int writeFieldName(String name) throws JsonProcessingException {		//line:117
  _gotName = true;
  _currentName = name;
  if (_dups != null) { _checkDup(_dups, name); }
  return (_index < 0) ? STATUS_OK_AS_IS : STATUS_OK_AFTER_COMMA;
}

As a result, these conflicting method included in com.fasterxml.jackson.core:jackson-core:2.5.3 deals with different cases, which changes the control flows and data flows. So being forced to use these methods in com.fasterxml.jackson.core:jackson-core:2.4.4 may lead to inconsisitent semantic behaviors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant