Bugs
andrei.eremeev
andrei.eremeev at oracle.com
Thu Mar 19 13:40:57 UTC 2015
Hi Jan,
Ok, this makes sense. You can postpone it.
Additionally, I have found that REPL crashes in the following test case:
> new testClasspathDirectory.pkg.A
Type tab and get the following crash.
Exception in thread "main"
com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file:
build/testClasspathDirectory/pkg/A.class
class file contains wrong class: pkg.A
Please remove or make sure it appears in the correct subdirectory of
the classpath.
at
com.sun.tools.javac.jvm.ClassReader.badClassFile(ClassReader.java:249)
at com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:2172)
at
com.sun.tools.javac.jvm.ClassReader.readClassBuffer(ClassReader.java:2283)
at
com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2294)
at com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:346)
at com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:285)
at com.sun.tools.javac.code.ClassFinder.access$000(ClassFinder.java:72)
at
com.sun.tools.javac.code.ClassFinder$1.complete(ClassFinder.java:159)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:569)
at
com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1053)
at com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:987)
at
com.sun.tools.javac.code.Symbol$TypeSymbol.getEnclosedElements(Symbol.java:735)
at
impl.SourceCodeAnalysisImpl.membersOf(SourceCodeAnalysisImpl.java:366)
at
impl.SourceCodeAnalysisImpl.computeSuggestions(SourceCodeAnalysisImpl.java:256)
at
impl.SourceCodeAnalysisImpl.completionSuggestions(SourceCodeAnalysisImpl.java:197)
at tool.ConsoleIOContext$1.complete(Repl.java:1081)
at jline.console.ConsoleReader.complete(ConsoleReader.java:3261)
at jline.console.ConsoleReader.readLine(ConsoleReader.java:2621)
at jline.console.ConsoleReader.readLine(ConsoleReader.java:2269)
at tool.ConsoleIOContext.readLine(Repl.java:1062)
at tool.Repl.run(Repl.java:322)
at tool.Repl.start(Repl.java:203)
at tool.Repl.start(Repl.java:182)
at tool.Repl.main(Repl.java:172)
Andrei Eremeev
On 03/19/2015 02:09 PM, Jan Lahoda wrote:
> Hi Andrei,
>
> Thanks for the steps to reproduce. I believe the problem is that both
> "build" and "build/testClasspathDirectory" are on the classpath, so
> when build/testClasspathDirectory/pkg/A.class file is found, a wrong
> binary name is inferred from the classfile name (the binary name is
> based on the build directory, and so it testClasspathDirectory.pkg.A
> instead of pkg.A). This seems like a corner case to me, so my proposal
> would be to not fix this now.
>
> What do you think?
>
> Thanks,
> Jan
>
> On 18.3.2015 12:13, andrei.eremeev wrote:
>> I can reproduce it in the following way:
>>
>> 1. Run all tests by scripts/test.sh
>> 2. Run REPL
>> 3. /cp build/testClasspathDirectory (one of directories generated by
>> tests with class pkg.A)
>> 4. new pk|
>>
>> I think I determine the root cause of the bug. When I try the same thing
>> with the absolute path, package completion works.
>>
>> Andrei Eremeev
>>
>> On 03/17/2015 05:07 PM, Jan Lahoda wrote:
>>> Hi Andrei,
>>>
>>> I tried to specify a directory for /cp, and the package completion
>>> still appears to work for me. Would you have more details on how to
>>> reproduce?
>>>
>>> Thanks a lot,
>>> Jan
>>>
>>> On 16.3.2015 15:49, andrei.eremeev wrote:
>>>> It looks like completion works for jars, but does not work for
>>>> directories.
>>>> I tried setting classpath by -classpath command line option and /cp
>>>> command shell.
>>>>
>>>> Andrei Eremeev
>>>>
>>>> On 03/16/2015 04:29 PM, Jan Lahoda wrote:
>>>>> Hi Andrei,
>>>>>
>>>>> Could you please be more specific - what should I do to see the
>>>>> problem with user classes? I tried to add a jar to the classpath
>>>>> using
>>>>> the "-classpath" command line option and using the "/cp" command, and
>>>>> the completion was completing the packages from the jars.
>>>>>
>>>>> For "new", there was a bug that packages were not listed after new,
>>>>> should be fixed now. Thanks for pointing that out.
>>>>>
>>>>> Thanks,
>>>>> Jan
>>>>>
>>>>> ----- Original Message -----
>>>>> From: andrei.eremeev at oracle.com
>>>>> To: jan.lahoda at oracle.com, robert.field at oracle.com,
>>>>> kulla-dev at openjdk.java.net
>>>>> Sent: Monday, March 16, 2015 1:24:08 PM GMT +01:00 Amsterdam / Berlin
>>>>> / Bern / Rome / Stockholm / Vienna
>>>>> Subject: Re: Bugs
>>>>>
>>>>> Yes, completion works for imports currently. But what about user
>>>>> defined
>>>>> classes in classpath?
>>>>> Let pkg.A be a user defined class. Completion does not work for both
>>>>> import statements and expression statements.
>>>>>
>>>>> > import pk|
>>>>> > new pk|
>>>>>
>>>>> Andrei Eremeev
>>>>>
>>>>> On 03/16/2015 03:16 PM, Jan Lahoda wrote:
>>>>>> On 15.3.2015 20:29, Robert Field wrote:
>>>>>>> That seems fine.
>>>>>> Thanks, completion for imports should work better now.
>>>>>>
>>>>>> Jan
>>>>>>
>>>>>>> It also suggests there might be ways for us to optimize the
>>>>>>> number of
>>>>>>> compiler tasks used.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Robert
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On March 15, 2015 11:22:13 AM Jan Lahoda <jan.lahoda at oracle.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> On 13.3.2015 19:06, Robert Field wrote:
>>>>>>>>> On 03/13/15 08:22, andrei.eremeev wrote:
>>>>>>>>>> Hi REPL team,
>>>>>>>>>>
>>>>>>>>>> Found bugs:
>>>>>>>>>>
>>>>>>>>>> 1. In completion analysis possible packages are not suggested.
>>>>>>>> "import
>>>>>>>>>> java.ut|".
>>>>>>>>> Jan?
>>>>>>>> Two problems here (thanks for report!):
>>>>>>>> -the completion did not complete packages in any context.
>>>>>>>> Should be
>>>>>>>> fixed now (is a little bit tricky, as it is not easy to get the
>>>>>>>> list of
>>>>>>>> packages, so completion is listing classes using the
>>>>>>>> JavaFileManager).
>>>>>>>> -completion misbehaving for imports in some cases (in
>>>>>>>> particular for
>>>>>>>> import static). To fix this, I'd like to change the way
>>>>>>>> AnalyzeTask
>>>>>>>> sets
>>>>>>>> AnalyzeTask.cut like this:
>>>>>>>> diff -r c9b090dded9b repl/src/impl/TaskFactory.java
>>>>>>>> --- a/repl/src/impl/TaskFactory.java Sun Mar 15 17:10:33 2015
>>>>>>>> +0100
>>>>>>>> +++ b/repl/src/impl/TaskFactory.java Sun Mar 15 19:16:09 2015
>>>>>>>> +0100
>>>>>>>> @@ -130,11 +130,9 @@
>>>>>>>>
>>>>>>>> AnalyzeTask(OuterWrap wrap, String... extraOptions) {
>>>>>>>> super(wrap, extraOptions);
>>>>>>>> - Iterator<? extends Element> eit =
>>>>>>>> analyze().iterator();
>>>>>>>> - if (eit.hasNext()) {
>>>>>>>> - Element e = eit.next();
>>>>>>>> - TreePath cutp = trees().getPath(e);
>>>>>>>> - this.cut = cutp.getCompilationUnit();
>>>>>>>> + Iterator<? extends CompilationUnitTree> cuts =
>>>>>>>> analyze().iterator();
>>>>>>>> + if (cuts.hasNext()) {
>>>>>>>> + this.cut = cuts.next();
>>>>>>>> //proc.debug("AnalyzeTask element=%s cutp=%s
>>>>>>>> cut=%s\n", e, cutp, cut);
>>>>>>>> } else {
>>>>>>>> this.cut = null;
>>>>>>>> @@ -142,9 +140,11 @@
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>> - private Iterable<? extends Element> analyze() {
>>>>>>>> + private Iterable<? extends CompilationUnitTree>
>>>>>>>> analyze() {
>>>>>>>> try {
>>>>>>>> - return task.analyze();
>>>>>>>> + Iterable<? extends CompilationUnitTree> cuts =
>>>>>>>> task.parse();
>>>>>>>> + task.analyze();
>>>>>>>> + return cuts;
>>>>>>>> } catch (Exception ex) {
>>>>>>>> throw new InternalError("Exception during
>>>>>>>> analyze - "
>>>>>>>> + ex.getMessage(), ex);
>>>>>>>> }
>>>>>>>>
>>>>>>>> Does this seem OK?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Jan
>>>>>>>>
>>>>>>>>>> 2. A user defined method/variable cannot hide a method/field
>>>>>>>> which has
>>>>>>>>>> been imported. (Maybe, a duplicate)
>>>>>>>>>> See ReplaceTest#testForwardSingleImportFieldToMethod,
>>>>>>>>>> ReplaceTest#
>>>>>>>>>> testForwardSingleImportMethodToMethod
>>>>>>>>> That is a duplicate, but I figured out a way to fix it. So far
>>>>>>>>> fixed
>>>>>>>>> for star imports. Still need to fix for named imports.
>>>>>>>>>
>>>>>>>>> Tests reenabled.
>>>>>>>>>
>>>>>>>>>> 3. This may not be a bug. Anyway, eval() returns string in
>>>>>>>>>> quotes
>>>>>>>> for
>>>>>>>>>> String type.
>>>>>>>>> I sent a query about desired proper behavior here. Got no
>>>>>>>>> responses.
>>>>>>>>> So, I'm leaving it, for now.
>>>>>>>>>
>>>>>>>>> -Robert
>>>>>>>>>
>>>>>>>>>> Andrei Eremeev
>>>>>>>
>>>>
>>
More information about the kulla-dev
mailing list