This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 239213 - Parsing Error after Refactor Copy
Summary: Parsing Error after Refactor Copy
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
: 236371 238552 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-12-06 22:13 UTC by bht
Modified: 2013-12-12 03:00 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Project in zip file (155.94 KB, application/octet-stream)
2013-12-07 02:15 UTC, bht
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bht 2013-12-06 22:13:54 UTC
The error occurred when I refactor copied a java source file from one package to another.

It appears that there are two errors: 1) that the java file's  class name and package statement etc. was not updated when it was refactor copied, and 2) that the copied file cannot be parsed.

The project files on computer 1 were stored on a network drive, which is possibly a factor in this. When I load the project on a different computer 2, locally, then there are no exceptions in the ide log, but the build fails with the messages

class OrganisationEditPage is public, should be declared in a file named OrganisationEditPage.java

OrganisationEditPage.java:[40,8] duplicate class: anon.web.pages.OrganisationEditPage

The message in the log asks for 7.4\var\log\OrgEditPage_6.dump but this file does not exist. Other dump files do exist however.

I think this is a serious issue because refactor copy has been implemented for some time and it should not fail with this type of error.
Comment 1 bht 2013-12-07 02:10:41 UTC
I can reproduce a refactor copy error on computer 2 with a freshly patched 7.4 IDE as follows:

1) Delete the failed source file mixed.org.web.pages.OrgEditPage. The project is now error free after scanning because nothing has been copied yet.
2) Again refactor copy from anon.web.pages.OrganisationEditPage.java to package mixed.org.web.pages, renaming it OrgEditPage
3) Edit the new OrgEditPage.java and inspect line 157

Expected result: 

Organisation organisation = OrgEditPage.OrganisationForm.this.getModelObject();

Actual result:
Organisation organisation = OrganisationEditPage.OrganisationForm.this.getModelObject();

The refactoring process should respect the "this" keyword for the inner class.

OrganisationEditPage.OrganisationForm.this refers to a class within the new file (this) and therefore OrganisationEditPage should have been renamed to OrgEditPage.
Comment 2 bht 2013-12-07 02:15:17 UTC
Created attachment 142928 [details]
Project in zip file

The project contains the erroneous file in the target package mixed.org.web.pages
Comment 3 Svata Dedic 2013-12-09 08:53:08 UTC
I was not able to reproduce the problem (1). Probably because of (1), the OrgEditPage refactored (and zipped in the attachment) does not contain inner classes (OrganizationForm etc). I could not reproduce this defect neither.

Should you come out with a semi-reliable way how to reproduce the above, please do open a new defect.

Passing the rest to refactoring support for further evaluation; even in my environment, the reference OrganisationEditPage.OrganisationForm.this.getModelObject() was not refactored to OrgEditPage.OrganisationForm.this.getModelObject() or OrganisationForm.this.getModelObject(). Degrading to P2, as it breaks the code, but is not that fatal.
Comment 4 Ralph Ruijs 2013-12-10 10:35:04 UTC
changeset   : ccccbe2d7ace
author      : Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
date        : Mon Dec 09 11:40:39 CET 2013
summary     : #239213 - Parsing Error after Refactor Copy
Comment 5 Ralph Ruijs 2013-12-10 13:28:52 UTC
*** Bug 236371 has been marked as a duplicate of this bug. ***
Comment 6 Ralph Ruijs 2013-12-10 13:29:37 UTC
*** Bug 238829 has been marked as a duplicate of this bug. ***
Comment 7 Ralph Ruijs 2013-12-10 13:30:18 UTC
*** Bug 238552 has been marked as a duplicate of this bug. ***
Comment 8 Quality Engineering 2013-12-12 03:00:03 UTC
Integrated into 'main-silver', will be available in build *201312120002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/ccccbe2d7ace
User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Log: #239213 - Parsing Error after Refactor Copy