Getting error "self constructor arguments cannot reference unconstructed this" only if class is same name as class file - eclipse

In a nutshell, if I define a constructor in a class thats named after the same name as the file itself, it returns the following area.
Some example code. Take the filename as ParseWebsiteData.scala for both.
This returns an error.
class ParseWebsiteData(url:String) {
}
This however, works fine.
class Foo(url:String) {
}
The only thing that I'm seeing as the issue are parser bugs from 2013, but this is the latest version of Eclipses's Scala IDE setup so I'm strongly thinking this is not the case, but turns out I'm wrong. Oops :(
As it's still an issue, what are the way(s) to avoid this occurring as I code in the future?

Well, can't tell the root cause but I was getting the same error in Scala Eclipse editor and I just did "project->clean" and it was gone!

Related

Breakpoints in Provides method get remapped in Eclipse to ProvidesAdapter instead

I am having an issue in Eclipse (with Dagger 1 still).
In dagger, for dependency injection (javax.inject), you create a Module class, with provides methods, like this:
#dagger.Module
class FooModule {
#dagger.Provides
Something provideSomething() {
return new Something();
}
}
And this will generate a class (using annotation processing) called FooModule$$ModuleAdapter$ProvideSomethingProvidesAdapter.
If I set a breakpoint in a provideSomething method in FooModule class (my code), Eclipse almost always actually stops on that same line number in the FooModule$$ModuleAdapter$ProvideSomethingProvidesAdapter class instead.
Does anyone know how to avoid this problem? I suspect this is likely an Eclipse issue where it is somehow is mapping the generated file to what it thinks is the "source" file, but that's of course not what I want.
Is there perhaps some setting in eclipse to avoid this problem?

Glimpse ADO fails in Web Site project with TableAdapters - Part 2

This is a follow up to this problem.
That problem was fixed. However, new compiler errors occurred. The compiler errors indicate the following:
The Glimpse.Ado.AlternateType.GlimpseDbCommand class needs a default constructor
The Glimpse.Ado.AlternateType.GlimpseDbConnection class needs a constructor that takes a string (connectionString)
This second problem is strange, because the System.Common.DbConnection class does not have a constructor that takes a string either.

GWT Deferred binding failed for custom class: No class matching "..." in urn:import:

I am developing a couple of custom widgets that I would like to be able to use with UiBinder. Unfortunately I keep wasting my life away with chasing down the following error:
No class matching "..." in urn:import:...
This seems to be the catch-all exception that is thrown any time there is any error in the class that prevents the GWT compiler from processing it. This includes anything in the class's entire dependency tree.
To save myself and anyone of you who is running into the same issue some time and pain, let's compile a list here of the most unexpected and hard to find causes for this. I'll start with my latest one, which has made me decide to post this here.
I was using a CellList thusly:
private static RelationshipViewerUiBinder uiBinder = GWT.create(RelationshipViewerUiBinder.class);
#UiField(provided=true)
CellList<String> prioritisedDisplay;
public RelationshipViewer() {
prioritisedDisplay = new CellList<>(new TextCell());
initWidget(uiBinder.createAndBindUi(this));
}
note the Java 7 style <> on the CellList. Despite my IDE's protestations to the contrary, it turns out you DO need to explicitly say CellList< String> in that new call, or it wont compile and all you get is the above mentioned error. Thanks by the way, the existance of this question prompted me to scrutinise my code and probably saved me a couple of hours! This fixed it:
private static RelationshipViewerUiBinder uiBinder = GWT.create(RelationshipViewerUiBinder.class);
#UiField(provided=true)
CellList<String> prioritisedDisplay;
public RelationshipViewer() {
prioritisedDisplay = new CellList<String>(new TextCell());
initWidget(uiBinder.createAndBindUi(this));
}
I had written a component that used the GWT JSON functionality, but hadn't imported com.google.gwt.json.JSON into the module.
Thanks to your message here, this was only 2 hours down the drain...
I wrote a helper-class that this widget uses somewhere deep inside its dependency tree.
For this helper-class, I told Eclipse to auto-generate the hashCode() and equals(...) functions. The class contained a field of type double, for which Eclipse generates code that uses Double.doubleToLongBits().
Turns out GWT does not implement this method on its version of Double. But of course, neither does Eclipse detect this as a possible compile-error, nor does it cause any issues in Dev Mode if I use the widget inside the GWT-App's Java code rather than inside UiBinder.
3 hours down the drain... Great... Yay for helpful error messages.
UPDATE:
As of GWT 2.5.0 (RC1) GWT now supports Double.doubleToLongBits() rendering this particular error obsolete, but the general error mechanism of a missing JRE emulation remains and will probably manifest itself in a similarly unhelpful way.
I was trying to use a GwtQuery DragAndDropCellTree in a UiBinder .ui.xml, which was impossible as DragAndDropCellTree has no zero-arg constructor.
See more details

How to refer to protected inner class in Scala when inheriting from Java (with byte code only)

I am writing a Scala class to inherit from a Java class, and I must override a method that takes a protected Java inner class as a parameter. The Java dependency comes as a jar without source code.
I have the exact same setup as found in https://issues.scala-lang.org/browse/SI-3120 except that I do not have the Java source code available, so scalac only knows about the Java dependency by looking at the byte code (in jar or class files).
This is basically what I'm trying to do:
// javapkg/JavaSuperClass.java
package javapkg;
public class JavaSuperClass {
protected class JavaInnerClass {
}
public void method(JavaInnerClass javaInnerclass) {
System.out.println("hello");
}
}
// scalapkg/ScalaSubClass.scala
package scalapkg
import javapkg.JavaSuperClass
class ScalaSubClass extends JavaSuperClass {
override def method(javaInnerClass: JavaSuperClass#JavaInnerClass) {
println("world")
}
}
I have Java Sun JDK Hotspot 1.6.0_24 and Scala 2.9.0.1 on Linux. This is what happens:
$ cd javapkg
$ javac JavaSuperClass.java
$ cd ../scalapkg
$ scalac -cp .. ScalaSubClass.scala
ScalaSubClass.scala:6: error: class JavaInnerClass in class JavaSuperClass cannot be accessed in javapkg.JavaSuperClass
Access to protected class JavaInnerClass not permitted because
prefix type javapkg.JavaSuperClass does not conform to
class ScalaSubClass in package scalapkg where the access take place
override def method(javaInnerclass: JavaSuperClass#JavaInnerClass) {
^
one error found
Note, if I change JavaSuperClass#JavaInnerClass to simply JavaInnerClass, I get this:
ScalaSubClass.scala:6: error: method method overrides nothing
override def method(javaInnerClass: JavaInnerClass) {
^
one error found
Note: I know this sounds very similar to the common "protected static inner class" Java-compatibility issue in Scala, but I believe this is unrelated because there are no statics anywhere in my example.
I feel like something is wrong, because when I put the same code into a mixed java/scala project in Eclipse, it seemed to compile fine (with the latter JavaInnerClass syntax); it's only when I compile the Scala code with only the Java byte code (and no Java source code) that I cannot get it to work. Am I just completely missing the correct syntax to refer to a Java inner class, is this a known defect, or should I file a compiler bug? I couldn't find anything about this exact use case in my searching.
This is an excellent article that discuss the topic.
EDIT-1
My bad, I answered to quickly. This actually may be a bug Mike, I'm trying to see if I can find a hack around. I'll let you know if I find one.
EDIT-2
I've tried different things but I can't find a way to make it work. Mike I'd suggest you to file a bug report.

StructureMap cannot find GenericRepository

In MVC 2 I am working on something and have ran into a snag. I got my repository put instead of putting in the same class the interface is I have it same project as the EDMX file.
Initializing StructureMap is what's killing me at this point. Here's where I'm initizing StructureMap (in Global.asax.cs.)
ObjectFactory.Initialize(x =>
{
x.ForRequestedType<IUnitOfWorkFactory>()
.TheDefaultIsConcreteType<EFUnitOfWorkFactory>()
.CacheBy(InstanceScope.HttpContext);
x.ForRequestedType(typeof(IRepository<>))
.CacheBy(InstanceScope.HttpContext)
.TheDefaultIsConcreteType(typeof(GenericRepository<>));
});
The Namespace for this project is GpdsCreationTaxidermy.Data (which is the same Namespace as my GenericRepository.cs). I would post the code for this file but I dont believe that is the problem here. In my Global.asax I import the proper Namespace
using GodsCreationTaxidermy.Data;
The error I'm getting is:
Error 3 The type or namespace name
'GenericRepository' could not be found
(are you missing a using directive or
an assembly reference?)
Also attached is an image showing this particular projects layout
Can someone help with this issue, or what I'm doing wrong here
EDIT I have even tried adding GodsCreationTaxidermy.Data to the file name and still no luck.
Thanks for sending the files :-)
It looks like the definition of GodsCreationTaxidermy.Data has changed.
This is what I did to fix the problem:
Remove these references from GodsCreationTaxidermy.Data.Repository Class Library:
GodsCreationTaxidermy.Data
GodsCreationTaxidermy.Data.Repository
Remove these references from GodsCreationTaxidermy.Data Class Library:
GodsCreationTaxidermy
GodsCreationTaxidermy.Data
Remove the reference to GodsCreationTaxidermy.Data in the GodsCreationTaxidermy MVC project and re-add the reference, choosing GodsCreationTaxidermy.Data from the Project tab
Hopefully that'll get the GenericRepository working :-)
I did notice that the following line no longer works though:
EFUnitOfWorkFactory.SetObjectContext(() => new GodsCreationTaxidermyEntities());
GodsCreationTaxidermyEntities doesn't seem to exist in GodsCreationTaxidermy.Data any more. Does that cause you an issue?
Try this:
.TheDefaultIsConcreteType(typeof(GodsCreationTaxidermy.Data.GenericRepository<>));
Possibly remove <> after GenericRepository. Has GodsCreationTaxidermy.Data been added to the MVC site as a reference?