Community
Participate
Working Groups
Consider the following code: ### package com.utopicmusic.app.web.seo; import java.sql.SQLException; import java.util.Map; import org.hibernate.HibernateException; import org.hibernate.Session; import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.orm.hibernate3.HibernateTemplate; public enum SitemapTypeJ { INDEX() { @Override public String getTemplatePath() { return getClass().getPackage().getName().replace('.', '/') + "/sitemap-index.ftl"; } @Override public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return null; } @Override public int countEntries(HibernateTemplate hibernateTemplate) { throw new UnsupportedOperationException("count not implemented for this sitemap type"); } }, ARTISTS() { @Override public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return null; } @Override public int countEntries(HibernateTemplate hibernateTemplate) { return hibernateTemplate.execute(new HibernateCallback<Integer>() { @Override public Integer doInHibernate(Session session) throws HibernateException, SQLException { return (Integer) session .createQuery( "select count(artist) from Artist as artist join artist.owner as user where user.active and artist.active") .uniqueResult(); } }).int| } }, CLUBS() { @Override public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return null; } @Override public int countEntries(HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return 0; } }, LISTENERS() { @Override public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return null; } @Override public int countEntries(HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return 0; } }, POSTS() { @Override public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return null; } @Override public int countEntries(HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return 0; } }, SONGS() { @Override public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return null; } @Override public int countEntries(HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return 0; } }, ALBUMS() { @Override public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return null; } @Override public int countEntries(HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return 0; } }, PLAYLISTS() { @Override public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return null; } @Override public int countEntries(HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return 0; } }, LOCATIONS() { @Override public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return null; } @Override public int countEntries(HibernateTemplate hibernateTemplate) { // TODO Stub di metodo generato automaticamente return 0; } }; /** * Returns the path within the classpath of the template that can be used to generate a sitemap of * this type. * * @return the full path within the classpath to retrieve the template */ public String getTemplatePath() { return getClass().getPackage().getName().replace('.', '/') + "/sitemap.ftl"; } /** * Builds the model and view for a sitemap of this type. * <p> * Actually, only a part of sitemap is built, containing up to 30,000 links at most. * * @param offset * the offset for the contents to include in the requested sitemap * @return the model and reference to the view name needed to generate this type of sitemap */ public abstract Map<String, Object> buildModel(final int offset, final HibernateTemplate hibernateTemplate); public abstract int countEntries(final HibernateTemplate hibernateTemplate); } ### To make it compile, put the following JARs on your buildpath: http://search.maven.org/remotecontent?filepath=org/hibernate/hibernate-core/3.6.10.Final/hibernate-core-3.6.10.Final.jar http://search.maven.org/remotecontent?filepath=org/springframework/spring-core/3.1.1.RELEASE/spring-core-3.1.1.RELEASE.jar http://search.maven.org/remotecontent?filepath=org/springframework/spring-orm/3.1.1.RELEASE/spring-orm-3.1.1.RELEASE.jar http://search.maven.org/remotecontent?filepath=org/springframework/spring-tx/3.1.1.RELEASE/spring-tx-3.1.1.RELEASE.jar Then, put your cursor at "|" and invoke code assist with Ctrl+Space, to search for "intValue()": the proposal is not given, you have to type "intValue()" by hand. Sorry, I was not able to provide a simpler reproducible test case.
This is a simpler case: public enum X { A() { public int count(Foo foo) { foo.returnInteger(new Foo() { }).intV|; return 0; } }; } class Foo { Integer returnInteger(Foo myClass) { return new Integer(0); } }
Srikanth, please follow up. The following code produces right proposals. The difference between this and the one from comment #1 is that in the former case the allocation expression gets all the statements, thus producing the right context and receiver. In the buggy one the statements are missing. class Foo { Integer returnInteger(Foo myClass) { return new Integer(0); } } class TestMain { public int foo() { Foo myClass = new Foo(); int i = myClass.returnInteger(new Foo() { }).intV; return i; } }
Apologies editing wrong bug
I won't be able to finish this one.
Will keep in my list, but no promise yet.
Thank you Jayaprakash!
Sorry, this needs to be moved out of 4.5.
Sorry, no hope for 4.6. Bulk moving to 4.7.
Bulk move out of 4.8
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
I can still reproduce the problem with the simple test case in comment #1 in 2019-12.
I can still reproduce the problem with the simple test case in comment #1 in 2022-06.