我不是处理这些东西的专家(修复IDE' s)但我得到了116个例外:
等于对象必须具有相同的哈希码。在重拍期间,Trove 发现以下两个对象声称是平等的(如 java.lang.Object.equals()或TObjectHashingStrategy.equals())但是 他们的hashCodes(或由你的TObjectHashingStrategy计算的) 是不平等的。这违反了一般合同 java.lang.Object.hashCode()。请参阅该方法中的第二点 文档。 object#1 = PsiArrayAccessExpression:args [0](类 com.intellij.psi.impl.source.tree.java.PsiArrayAccessExpressionImpl) 的hashCode = 1492582784; object#2 = PsiArrayAccessExpression:args [0] (类 com.intellij.psi.impl.source.tree.java.PsiArrayAccessExpressionImpl) hashCode = 1492582784:等于对象必须具有相等的哈希码。中 重复,Trove发现以下两个对象声称是 等于(如java.lang.Object.equals()或 TObjectHashingStrategy.equals())但是他们的hashCodes(或那些 由你的TObjectHashingStrategy计算得并不相等。这违反了 java.lang.Object.hashCode()的常规协定。见子弹点 两个在该方法的文档中。对象#1 = PsiArrayAccessExpression:args [0](类com.intellij.psi.impl.source.tree.java.PsiArrayAccessExpressionImpl), 的hashCode = 1492582784; object#2 = PsiArrayAccessExpression:args [0] (类 com.intellij.psi.impl.source.tree.java.PsiArrayAccessExpressionImpl) 的hashCode = 1492582784
即使在重新启动IDE后,它仍然会给我带来麻烦。 它不会自动建议或填充变量/函数等。我必须让我的应用程序字面上只是记住事情,我该如何解决这个问题?这很烦人。
我注意到每次按Ctrl + Space时都会抛出它(对于自动建议)。
帮助?
更新
> Equal objects must have equal hashcodes. During rehashing, Trove
> discovered that the following two objects claim to be equal (as in
> java.lang.Object.equals() or TObjectHashingStrategy.equals()) but
> their hashCodes (or those calculated by your TObjectHashingStrategy)
> are not equal.This violates the general contract of
> java.lang.Object.hashCode(). See bullet point two in that method's
> documentation. object #1 =PsiArrayAccessExpression:args[0] (class
> com.intellij.psi.impl.source.tree.java.PsiArrayAccessExpressionImpl),
> hashCode=1492582784; object #2 =PsiArrayAccessExpression:args[0]
> (class
> com.intellij.psi.impl.source.tree.java.PsiArrayAccessExpressionImpl),
> hashCode=1492582784: Equal objects must have equal hashcodes. During
> rehashing, Trove discovered that the following two objects claim to be
> equal (as in java.lang.Object.equals() or
> TObjectHashingStrategy.equals()) but their hashCodes (or those
> calculated by your TObjectHashingStrategy) are not equal.This violates
> the general contract of java.lang.Object.hashCode(). See bullet point
> two in that method's documentation. object #1
> =PsiArrayAccessExpression:args[0] (class com.intellij.psi.impl.source.tree.java.PsiArrayAccessExpressionImpl),
> hashCode=1492582784; object #2 =PsiArrayAccessExpression:args[0]
> (class
> com.intellij.psi.impl.source.tree.java.PsiArrayAccessExpressionImpl),
> hashCode=1492582784 java.lang.IllegalArgumentException: Equal objects
> must have equal hashcodes. During rehashing, Trove discovered that the
> following two objects claim to be equal (as in
> java.lang.Object.equals() or TObjectHashingStrategy.equals()) but
> their hashCodes (or those calculated by your TObjectHashingStrategy)
> are not equal.This violates the general contract of
> java.lang.Object.hashCode(). See bullet point two in that method's
> documentation. object #1 =PsiArrayAccessExpression:args[0] (class
> com.intellij.psi.impl.source.tree.java.PsiArrayAccessExpressionImpl),
> hashCode=1492582784; object #2 =PsiArrayAccessExpression:args[0]
> (class
> com.intellij.psi.impl.source.tree.java.PsiArrayAccessExpressionImpl),
> hashCode=1492582784 at
> gnu.trove.TObjectHash.throwObjectContractViolation(TObjectHash.java:318)
> at gnu.trove.THashMap.rehash(THashMap.java:350) at
> gnu.trove.THash.postInsertHook(THash.java:283) at
> gnu.trove.THashMap.put(THashMap.java:175) at
> com.intellij.codeInsight.guess.impl.GuessManagerImpl$2.visitTypeCastExpression(GuessManagerImpl.java:177)
> at
> com.intellij.psi.impl.source.tree.java.PsiTypeCastExpressionImpl.accept(PsiTypeCastExpressionImpl.java:98)
> at com.intellij.psi.PsiWalkingState.visit(PsiWalkingState.java:61)
> at com.intellij.psi.PsiWalkingState.visit(PsiWalkingState.java:26)
> at com.intellij.util.WalkingState.walkChildren(WalkingState.java:65)
> at
> com.intellij.util.WalkingState.elementStarted(WalkingState.java:52)
> at
> com.intellij.psi.PsiWalkingState.elementStarted(PsiWalkingState.java:70)
> at
> com.intellij.psi.JavaRecursiveElementWalkingVisitor.visitElement(JavaRecursiveElementWalkingVisitor.java:34)
> at
> com.intellij.codeInsight.guess.impl.GuessManagerImpl$2.visitElement(GuessManagerImpl.java:198)
> at
> com.intellij.psi.JavaElementVisitor.visitCodeBlock(JavaElementVisitor.java:68)
> at
> com.intellij.psi.impl.source.tree.java.PsiCodeBlockImpl.accept(PsiCodeBlockImpl.java:202)
> at
> com.intellij.codeInsight.guess.impl.GuessManagerImpl.getAllTypeCasts(GuessManagerImpl.java:171)
> at
> com.intellij.codeInsight.guess.impl.GuessManagerImpl.getControlFlowExpressionType(GuessManagerImpl.java:380)
> at
> com.intellij.codeInsight.completion.JavaCompletionUtil.getQualifierCastType(JavaCompletionUtil.java:416)
> at
> com.intellij.codeInsight.completion.JavaCompletionUtil.processJavaReference(JavaCompletionUtil.java:355)
> at
> com.intellij.codeInsight.completion.JavaCompletionContributor$5.consume(JavaCompletionContributor.java:312)
> at
> com.intellij.codeInsight.completion.JavaCompletionContributor$5.consume(JavaCompletionContributor.java:300)
> at
> com.intellij.codeInsight.completion.LegacyCompletionContributor.processReference(LegacyCompletionContributor.java:123)
> at
> com.intellij.codeInsight.completion.LegacyCompletionContributor.processReferences(LegacyCompletionContributor.java:106)
> at
> com.intellij.codeInsight.completion.JavaCompletionContributor.addReferenceVariants(JavaCompletionContributor.java:300)
> at
> com.intellij.codeInsight.completion.JavaCompletionContributor.fillCompletionVariants(JavaCompletionContributor.java:239)
> at
> com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:84)
> at
> com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:132)
> at
> com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:125)
> at
> com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:112)
> at
> com.intellij.codeInsight.completion.JavaNoVariantsDelegator.fillCompletionVariants(JavaNoVariantsDelegator.java:46)
> at
> com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:84)
> at
> com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:132)
> at
> com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:125)
> at
> com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor$1.addCompletions(LiveTemplateCompletionContributor.java:75)
> at
> com.intellij.codeInsight.completion.CompletionProvider.addCompletionVariants(CompletionProvider.java:36)
> at
> com.intellij.codeInsight.completion.CompletionContributor.fillCompletionVariants(CompletionContributor.java:155)
> at
> com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:84)
> at
> com.intellij.codeInsight.completion.CompletionService.performCompletion(CompletionService.java:115)
> at
> com.intellij.codeInsight.completion.CompletionProgressIndicator.calculateItems(CompletionProgressIndicator.java:769)
> at
> com.intellij.codeInsight.completion.CompletionProgressIndicator.access$900(CompletionProgressIndicator.java:84)
> at
> com.intellij.codeInsight.completion.CompletionProgressIndicator$1CalculateItems.run(CompletionProgressIndicator.java:751)
> at
> com.intellij.codeInsight.completion.AsyncCompletion$1$1$1.run(CompletionThreading.java:93)
> at
> com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:911)
> at
> com.intellij.codeInsight.completion.AsyncCompletion$1$1.run(CompletionThreading.java:88)
> at
> com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
> at
> com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
> at
> com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
> at
> com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
> at
> com.intellij.codeInsight.completion.AsyncCompletion$1.run(CompletionThreading.java:84)
> at
> com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:419)
> at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266) at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745) at
> com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:149)
答案 0 :(得分:0)
对于那些看过这几年但仍然无法找到解决方案的人,我遇到了同样的问题并最终解决了问题。如果你遇到类似的情况,请参见下文。
我的问题是使用JSONObject和JSONArray对象。基本上,我会读取一个JSONObject,并尝试在第一个JSONObject中获取另一个JSONObject
假设您正在阅读此消息:
{
"sub1": ["array element 1", "array element 2", "array element 3"],
"sub2": {
"name": "name for sub-object sub2",
"value": "value for sub-object sub2 or whatever"
}
}
让我们说整个对象是args[0]
给我的,然后我正在做的就是这样:
JSONObject globalObject = (JSONObject) args[0];
JSONArray sub1= (JSONArray) globalObject.get("sub1");//<-- the problem
JSONObject sub2 = (JSONObject) globalObject.get("sub2");//<-- also the problem
String arrayElement1 = sub1.get(0);
String nameSub2 = sub2.getString("name");
<强>解决方案强>
问题来自于将内容从JSONObject / JSONArray的get()
方法转换为JSONObject / JSONArray。没有必要这样做,因为您可以getJSONObject(/*value*/)
或getJSONObject(/*value*/)
,并获得已经类型为JSONObject
或JSONArray
所以我上面的代码应该是这样的:
JSONObject globalObject = (JSONObject) args[0];//<--only this needs to be casted
JSONArray sub1= globalObject.getJSONArray("sub1");//<-- got rid of the castnig
JSONObject sub2 = globalObject.getJSONObject("sub2");//<-- no more casting
String arrayElement1 = sub1.get(0);
String nameSub2 = sub2.getString("name");
希望这有助于某人。