Google Guava Trunk Build Problem - java

I am asking this question on stackoverflow as this is the suggested guava question forum indicated on the guava website (http://code.google.com/p/guava-libraries/).
I want to try out some of the unreleased new features of google guava (like the cool MoreExecutors.listeningDecorator feature). As I haven't found a google guava nightly build, I decided to try to create the jar myself. Unfortunately I am seeing the following exception from javac (on Mac OS 10.6.8) when I try to build:
[javac] An exception has occurred in the compiler (1.6.0_24). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
[javac] java.lang.NullPointerException
[javac] at com.sun.tools.javac.comp.Check.checkCompatibleConcretes(Check.java:1215)
[javac] at com.sun.tools.javac.comp.Check.checkCompatibleSupertypes(Check.java:1567)
[javac] at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2674)
[javac] at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2628)
[javac] at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2564)
[javac] at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1036)
[javac] at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:765)
[javac] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:730)
.
.
I see that I am not alone in this error:
http://gump.zones.apache.org/gump/public/google-guava/google-guava/gump_work/build_google-guava_google-guava.html
I understand this looks like a Java compiler bug, but is there perhaps a workaround to get guava to compile? Or if not, is there a recent guava nightly build somewhere which I could use instead?

I can't see any error on the page you've linked to (it shows a successful build). Maybe this has been fixed? Or did you possible attach the wrong URL?
I'd try OpenJDK.
If this is a bug in the com.sum.* libraries then you may find that OpenJDK does not suffer with the same problem.

Related

assertNotEquals static import causing compile error

I have a file Foo.java which compiles with no errors. But when I add the single line
import static org.junit.Assert.assertNotEquals;
This causes the following error from my ant build:
compileTests:
[javac] Compiling 27 source files to C:\example\bin
[javac] C:\example\src\Foo.java:7: error: cannot find symbol
[javac] import static org.junit.Assert.assertNotEquals;
[javac] ^
[javac] symbol: static assertNotEquals
[javac] location: class
[javac] 1 error
I am using JUnit 4.4. junit-4.4.jar is included in the classpath for the javac task.
I have tried running different compiler versions with the flags -Dbuild.compiler=javac1.7 and -Dbuild.compiler=javac1.8 but it makes no difference. I still get the exact same error.
assertNotEquals is the only static import from Assert that causes this error.
I have already seen this post Java static import causing compile error. Probable compiler bug?
and I tried importing Assert on its own and prepending each assert statement with Assert. like this post suggested. I got the same error, this time at the method call for Assert.assertNotEquals()instead of the import statement.
The import successfully compiles and runs on Eclipse, however.
Does anyone have any ideas about the cause of this? I'd like to get to the bottom of this instead of having to implement a workaround solution.
You are using Junit 4.4. AssertNotEquals wasn't added until 4.11
JUnit 4.11 release Notes
If you update to the latest JUnit jar. the compiler error should go away. Eclipse is probably using its own built in version that has the latest methods.

Project compiles with Ant. But if I open eclipse, the project no longer compiles

I'm on Windows.
I downloaded the source to a java project (Plovr) and I can build it with ant using cygwin.
But just opening it in Eclipse means it will never build again. If I open it in Eclipse and then close it again, it will no longer build. I also can't add files that were written in Eclipse.
Output:
javacc:
compile:
[javac] Compiling 7 source files to C:\Users\Bryana\plovr\pulled\plovr-master\build\classes
[javac] C:\Users\Bryana\plovr\pulled\plovr-master\closure\closure-stylesheets\build\genfiles\java\com\google\common\css\compiler\ast\GssParserCC.java:345: error: cannot access Type
[javac] public CssBooleanExpressionNode buildBoolExpressionNode(CssBooleanExpressionNode.Type type,
[javac] ^
[javac] bad class file: C:\Users\Bryana\plovr\pulled\plovr-master\build\classes\com\google\common\css\compiler\ast\CssBooleanExpressionNode$Type.class
[javac] bad signature: ▒3i
[javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
BUILD FAILED
Using: jdk1.7.0_40 , Apache Ant(TM) version 1.9.2 , Eclipse Juno Service Release 2
Found this: http://suneelgv.wordpress.com/2011/02/17/java-lang-classformaterror-invalid-constant-pool-index-63-bad-class-file/ referring to that http://mail-archives.apache.org/mod_mbox/cayenne-user/200804.mbox/%3C0JZC008038T159#mail.uni-rostock.de%3E.
In your case the filterset or similar on-the-fly modification during copying - accidentally including class files - might not do any harm with Unix but convert line endings on Windows.

Liferay Developer Studio not resolving package com.liferay.portal.upload

I'm trying to customize the Liferay Web Forms portlet to accept a file control, and I've just about gotten everything working except for the UploadPortletRequest to handle the actual uploading of the file from the form!
I've got:
import com.liferay.portal.upload.UploadPortletRequestImpl;
and in the compiler output:
[javac] 1. ERROR in C:\Program Files\Liferay Developer Studio\liferay-plugins-sdk-6.0-ee-sp2-20110727\portlets\AZ_WebForms-portlet\docroot\WEB-INF\src\com\liferay\autozone\webform\portlet\AZ_WebForm.java (at line 34)
[javac] import com.liferay.portal.upload.UploadPortletRequestImpl;
[javac] ^^^^^^^^^^^^^^^^^^^^^^^^^
[javac] The import com.liferay.portal.upload cannot be resolved
BUT...If I add portal-impl.jar to the Portal Dependency JARs to be able to resolve the class, it won't compile because portal-impl.jar is in WEB-INF/lib!! (and it doesn't like that)
I'm kind of at a loss here. What do I need to do?
You can't use anything from portal-impl.jar, unless you use ext environment and you modify Liferay.
From your compiler output I would say that you are writing your own portlet, not customizing existing. Am I wrong?
You must handle upload your self. Yyou can use Apache commons fileupload, it supports portlets.
Pleas see Using FileUpload, specifically Servlets and portlets part

Lucene: Cannot find symbol

I am using Lucene 3.4.0, hibernate (hibernate-all.jar), ANT and TestNG to run some test...
Most of all works right now, but since I have implemented my lucene part nothing seems to work when I use ant command... I'm kind of lost here.
Because everything works perfectly locally. I can run my test, compile, etc. As soons as, I try to build with ant, I get this error "cannot find symbol" for contructor StandartAnalyzer(version.), etc...
But like I said, everything works on eclipse... At first, I had an method not found error, but fixed it because hibernate is not compatible with the latest version of lucene. So I upgraded hibernate... but now, I get this.
Thank you. If you need more information plz ask.
$ ant explode
Buildfile: c:\DuplicateBugFinder\dbf\build.xml
init:
groovy.compile:
groovy.copy:
compile:
[javac] c:\DuplicateBugFinder\dbf\build.xml:156: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=l
st; set to false for repeatable builds
[javac] Compiling 27 source files to c:\DuplicateBugFinder\dbf\exploded-archives\dbf.ear\dbf_jar
[javac] c:\DuplicateBugFinder\dbf\src\hot\com\rim\sts\dbf\business\service\classification\LuceneClassificationAlgorithm.java:
6: cannot find symbol
[javac] symbol : constructor StandardAnalyzer(org.apache.lucene.util.Version)
[javac] location: class org.apache.lucene.analysis.standard.StandardAnalyzer
[javac] Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_34);
[javac] ^
[javac] c:\DuplicateBugFinder\dbf\src\hot\com\rim\sts\dbf\business\service\classification\LuceneClassificationAlgorithm.java:
2: cannot find symbol
[javac] symbol : constructor QueryParser(org.apache.lucene.util.Version,java.lang.String,org.apache.lucene.analysis.Analyzer
[javac] location: class org.apache.lucene.queryParser.QueryParser
[javac] new QueryParser(Version.LUCENE_34, "title", analyzer)
[javac] ^
[javac] c:\DuplicateBugFinder\dbf\src\hot\com\rim\sts\dbf\business\service\classification\LuceneClassificationAlgorithm.java:
9: cannot find symbol
[javac] symbol : constructor IndexSearcher(org.apache.lucene.store.Directory,boolean)
[javac] location: class org.apache.lucene.search.IndexSearcher
[javac] searcher = new IndexSearcher(index, true);
[javac] ^
[javac] c:\DuplicateBugFinder\dbf\src\hot\com\rim\sts\dbf\business\service\classification\LuceneClassificationAlgorithm.java:
00: cannot find symbol
[javac] symbol : method search(org.apache.lucene.search.Query,org.apache.lucene.search.TopScoreDocCollector)
[javac] location: class org.apache.lucene.search.IndexSearcher
[javac] searcher.search(q, collector);
[javac] ^
[javac] 4 errors
BUILD FAILED
c:\DuplicateBugFinder\dbf\build.xml:156: Compile failed; see the compiler error output for details.
It's probablly a difference in the classpathes used by Eclipse and by Ant respectively. Check what jars are you exactly using inside Eclipse (what libraries are added to the project) and then what jars you use in your declared Ant classpath when you build with that. Also check that you're using the same JDK in Eclipse and Ant. If either of the two differ, change Ant ones to be like Eclipse (since that's the environment that does work)
Check the ant classpath for multiple versions of Lucene library. Do ant -diagnostics to check the ant environment.
Ok fixed it. I needed to add the jar file in my lib/test (I'm using seam framework). In eclipse, everything was working because I was pointing to the jar in my run configurations for TestNG. When I was running the command "ant test" no jar was found...
So thanks to everyone.
Plus, for those of you who wants to make use of lucene and seam make sure too have no version incompatibilty. I had this problem for a long time. Finally, I found out that I had to use an older version of lucene (2.4.1) to work with seam 2.2. I didn't check yet for lucene 3.4 and seam 3...

javac can't find classes in .jar even though they are present?

I'm including a rather large JAR file during compilation that I'm generating using Altova MapForce. The JAR file was around 65MB and compilation was working fine. I needed to add a bunch more mappings, so I did, regenerated my JAR, and tried building again. The JAR is now around 80MB.
Now I get all kinds of "cannot find symbol" error messages even though I've opened the JAR to verify that the symbols are there! Am I hitting some upper limit on JAR sizes? There are over 75,000 classes inside the JAR file.
What's weird is that Eclipse auto-completion works just fine with the new JAR; I only get these errors when building.
I'm using Ant if that makes any difference.
Thanks,
Brian
EDIT: Something else strange: I turned on the verbose output from javac. It seems that I start getting compile errors even before all of the classes are loaded:
[javac] [loading com\mycompany\myproject\*************************.class)]
[javac] [loading com\mycompany\myproject\*************************.class)]
[javac] [loading com\mycompany\myproject\*************************.class)]
[javac] [loading com\mycompany\myproject\*************************.class)]
[javac] [loading com\mycompany\myproject\*************************.class)]
[javac] C:\Users\*************************.java:38: cannot find symbol
[javac] symbol : class *************************
[javac] location: package com.mycompany.myproject.*************************
[javac] import com.mycompany.myproject.*************************;
[javac] ^
[javac] [loading com\altova\TraceProvider.class(com\altova:TraceProvider.class)]
[javac] [loading com\altova\io\StringInput.class(com\altova\io:StringInput.class)]
[javac] [loading com\altova\io\StringOutput.class(com\altova\io:StringOutput.class)]
It would be helpful to see the specific compiler errors you're getting, your classpath, etc. If it works from eclipse and not in ant, it's likely to be a classpath issue, i.e. your ant script is not setting the same classpath as your project settings in eclipse has.
I work on one project that has a jar file larger than 80MB no problem, and I don't think there's an upper limit on number of classes in a jar file or anything like that. the size of the jar and the number of classes it contains is unlikely to be your problem.
you can try writing a simple test main program that just imports the classes in question, and compile that with javac with only that jar on your classpath. if that test doesn't work, you know you've got a problem with the jar you're using. if it doesn't work, is has got to be either an ant issue or similar.
can you post your ant build target, and the verbose output of ant?
Well, I've solved the problem. All I did was regenerate my JAR (I didn't change anything!) and it worked. Seems like it was just a fluke.
Sorry to waste everyone's time!
I had exactly this problem, when building via Ant on Jenkins.
The class which is not found is shown loading after the error: "Cannot find symbol" shows up in the verbose output. Tried rebuilding numerous times, no joy.
Finally, I went to the class importing the class not found, and changed the order of imports so the problem class was nearer the top. This is a temporary fix, as soon as someone organizes the imports in Eclipse, they will be sorted in an order that Javac will fail to load. We may have to rename the class, so it sorts to the top of the imports.
After some more research, I found this is related to bug 7101822 in Java, where eager loading of the classes can result in "Cannot find symbol" error.
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7101822

Categories